Re: [PERFORM] Subselect query enhancement

2007-02-02 Thread Richard Huxton
Michael Artz wrote: Here are some numbers for 3 different queries using a very selective query (port = ). I'm thinking that, since the row estimates are different from the actuals (2 vs 2000), that this particular port didn't make it into the statistics ... is that true? Does this matter?

Re: [PERFORM] Subselect query enhancement

2007-02-01 Thread Andrew Lazarus
>> How about this option: >> >> SELECT distinct ip_info.* FROM ip_info RIGHT JOIN network_events USING >> (ip) RIGHT JOIN host_events USING (ip) WHERE >> (network_events.name='blah' OR host_events.name = 'blah') AND >> ip_info.ip IS NOT NULL; MA> Nah, that seems to be much much worse. The othe

Re: [PERFORM] Subselect query enhancement

2007-02-01 Thread Michael Artz
Here are some numbers for 3 different queries using a very selective query (port = ). I'm thinking that, since the row estimates are different from the actuals (2 vs 2000), that this particular port didn't make it into the statistics ... is that true? Does this matter? If this isn't enough

Re: [PERFORM] Subselect query enhancement

2007-02-01 Thread Richard Huxton
Michael Artz wrote: > I have primary table that holds ip information > and two other tables that hold event data for the specific IP in with > a one-to-many mapping between them, ie: [snip] > There is quite a bit of commonality between the network_events and > host_events schemas, but they do no

Re: [PERFORM] Subselect query enhancement

2007-02-01 Thread Michael Artz
> I have primary table that holds ip information > and two other tables that hold event data for the specific IP in with > a one-to-many mapping between them, ie: [snip] > There is quite a bit of commonality between the network_events and > host_events schemas, but they do not currently share an

Re: [PERFORM] Subselect query enhancement

2007-02-01 Thread Frank Wiles
On Thu, 1 Feb 2007 11:42:03 -0500 "Michael Artz" <[EMAIL PROTECTED]> wrote: > I'm needing help determining the best all-around query for the > following situation. I have primary table that holds ip information > and two other tables that hold event data for the specific IP in with > a one-to-man

Re: [PERFORM] Subselect query enhancement

2007-02-01 Thread Michael Artz
How about this option: SELECT distinct ip_info.* FROM ip_info RIGHT JOIN network_events USING (ip) RIGHT JOIN host_events USING (ip) WHERE (network_events.name='blah' OR host_events.name = 'blah') AND ip_info.ip IS NOT NULL; Nah, that seems to be much much worse. The other queries usually re

Re: [PERFORM] Subselect query enhancement

2007-02-01 Thread Ted Allen
I've found that doing joins seems to produce better results on the big tables queries I use. This is not always the case though. How about this option: SELECT distinct ip_info.* FROM ip_info RIGHT JOIN network_events USING (ip) RIGHT JOIN host_events USING (ip) WHERE (network_events.name='b

Re: [PERFORM] Subselect query enhancement

2007-02-01 Thread Richard Huxton
Michael Artz wrote: I'm needing help determining the best all-around query for the following situation. Not sure whether such a beast exists, but... > I have primary table that holds ip information and two other tables that hold event data for the specific IP in with a one-to-many mapping be

[PERFORM] Subselect query enhancement

2007-02-01 Thread Michael Artz
I'm needing help determining the best all-around query for the following situation. I have primary table that holds ip information and two other tables that hold event data for the specific IP in with a one-to-many mapping between them, ie: CREATE TABLE ip_info ( ip IP4, --other data ); C