Hi,

Can anyone suggest a good way to optimize the following query?

CREATE TABLE propositions (
  verb_id INTEGER NOT NULL,
  tag VARCHAR(10) NOT NULL,
  start INTEGER NOT NULL,
  stop INTEGER NOT NULL );

CREATE TABLE output (
  verb_id INTEGER NOT NULL,
  tag VARCHAR(10) NOT NULL,
  start INTEGER NOT NULL,
  stop INTEGER NOT NULL );

...insert a bunch of rows into the two tables...

SELECT count(*) FROM propositions p, output o
 WHERE p.verb_id=o.verb_id
   AND p.tag=o.tag
   AND (p.stop!=o.stop OR p.start!=o.start);


In other words, I'm trying to count corresponding rows in the two tables
(same verb_id and tag) that don't have the same stop or start value.
Unfortunately, there's no good unique ID for the table - my best inclination
is to simply create an index on (verb_id, tag).  Is that the best I can do
here?  

It seems like with an index on (verb_id, tag), the query will step through
the index on "propositions", then repeatedly search through the index on
"output" (or vice versa).  Any way to get it to step through the two indexes
in parallel?

 -Ken

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to