[SQL] how can I improve the speed of this query

2002-11-15 Thread Peter T. Brown
Hi-- I have this rather long complex query that takes really long to complete (please see below). It seems like I ought to improve the speed somehow. I don't understand, for example, what the query planner is doing when it says "Hash" and why this appears to take so long. And since I have a key fo

[SQL] making queries more effecient

2002-11-01 Thread Peter T. Brown
Hi. I have this query that I have been trying to reduce to a single statement, but haven't figured out how. Am I missing something? CREATE TEMP TABLE temp20561149207391 AS SELECT DISTINCT ON ("VisitorID") "VisitorID","Type" FROM "ProgramEvent" WHERE "ProgramID" = 10 ORDER BY "VisitorID","Created"