Subject | Slow descending order select on joint tables |
---|---|
Author | firebird_tmc |
Post date | 2006-09-18T21:28:13Z |
First, I query a table in descending order.
select first 250 * from table_A A
where A.time > sometimestamp
order by A.ID desc
ID is the primary key. After creating a descending index on ID, the
query takes about 50ms.
I need to furtherly join table_A to a small table with only 5 records.
Now the query is revised as:
select first 250 * from table_A A
left join table_B B
on A.column = B.column
where A.time > sometimestamp
order by A.ID desc
Now it takes more than 1 minute :-(
Can anyone please point out what is missing here?
Best,
Sean
select first 250 * from table_A A
where A.time > sometimestamp
order by A.ID desc
ID is the primary key. After creating a descending index on ID, the
query takes about 50ms.
I need to furtherly join table_A to a small table with only 5 records.
Now the query is revised as:
select first 250 * from table_A A
left join table_B B
on A.column = B.column
where A.time > sometimestamp
order by A.ID desc
Now it takes more than 1 minute :-(
Can anyone please point out what is missing here?
Best,
Sean