0

I have a table...

FactorID, col1 col2     Factor Value
1         a     2        1231
1         b     3        2342
2         a     2        1233
2         b     3        2344

That mean ... For factor Id 1, I have 1500 records...and factor Id 2 I have same number of records.

For Factor Ids 1 &2 every values are same except "Factor Value".

When I join above table with some other tables to fetch data... FactorID 1 gives me quick results...but when I query for "2" ...the execution never ends.

This seems to be weird eror to me. Is it something related to row-lock ? Please helpme.

Relativity
  • 6,690
  • 22
  • 78
  • 128

2 Answers2

1

It could be that the join is using a table scan. Check whether FactorID has got an index. The results you are seeing might be because FactorID 1 records are first in the table and when it comes to FactorID 2, it goes on skipping records for FactorID1 one by one until it comes to FactorID 2.

Rasika
  • 1,980
  • 13
  • 19
0

 

When I join above table with some other tables to fetch data... FactorID 1 gives me quick results... but when I query for "2" ...the execution never ends.


Wow, that's saying very little.

The answer depends on three things.

  1. How are your tables defined?
    • Do you have primary keys? Which columns are keys? If there are only two "FactorID" values in the table shown above, that would be a poor choice for a primary key.
    • Are any other columns indexed?
    • Do you actually have columns named "col1" and "col2"? Or are you just saying, "the names don't matter"?
    It matters how the OTHER tables are defined too. Do they have any keys?
     
  2. What type of data is in the tables? How many rows?
     
  3. The most important thing: What do you mean by "when I join table with some other tables"? How many tables are being joined? How are you doing the joins?

Plus, you say that your query "never ends" - how long did you wait?

Sorry, but we need a LOT more information before a meaningful answer can be given.

Allan W
  • 580
  • 1
  • 3
  • 8