| From: | "Chigoy, Byron T" <BTChigoy(at)pbsj(dot)com> |
|---|---|
| To: | <pgsql-novice(at)postgresql(dot)org> |
| Subject: | Optimizing Query (Index) |
| Date: | 2008-03-07 20:18:56 |
| Message-ID: | 122502B78C78054FBB07941953DD249E98CEB9@CP-MBX01.pbsj.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-novice |
Hi,
I have two tables; table1 has 3500 records (small table) and table2
(bigtable) has 25 million records.
I need to Inner Join the two tables based on two columns in each table.
My query reads (I have changed the literal names here for easier
reading):
SELECT sm.recordid, sm.areaid, bg.distance
FROM smalltable sm
INNER JOIN bigtable bg ON (bg.originid=sm.originid AND
bg.detinationid=sm.detinationid)
WHERE sm.somecondition>0
I have tried indexing the originid and destinationid columns in both
tables, and indexed the somecondition column but my query is still
running extraordinarily slow. I looked at the query plan, and it seems
that my query plan only references the index on the somecondition
column. I need to make this run much faster, any tips?
Regards,
B
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Obe, Regina | 2008-03-07 21:43:21 | Re: Optimizing Query (Index) |
| Previous Message | Raimon Fernandez | 2008-03-07 18:49:04 | Re: numeric definition advice |