List:General Discussion« Previous MessageNext Message »
From:Dan Nelson Date:July 28 2004 2:58pm
Subject:Re: Indexed Database still slow
View as plain text  
In the last episode (Jul 28), SGreen@stripped said:
> I think the UNION is the right way to handle this, in fact, I would be
> tempted to break it into 6 UNIONS... more on that later.

I think his 2 original unions should suffice.  Unions are great for
overcoming mysql's "one index per table" limitation when you have ORs in
your query referring to different fields.  You don't need to split up the
ORs within those WHERE clauses because they're all looking at the same
field.  You could even tidy the query up a bit by using the IN clause:

Where PRTC_DIALUP.Framed_IP_Address = 'someipaddress' 
AND PRTC_DIALUP.Date in ('one-date-here','one-day-earlier')

but that's just syntax changes.  Mysql will process it the same way.  Two
indexes, one on PRTC_DIALUP (Framed_IP_Address, Date) and the other on
PRTC_DSL (Framed_IP_Address, Date) should be all Christopher needs.

Also use the EXPLAIN command to find out exactly what MySQL decides to do
for the query.  Chapter 7.2 of the mysql manual covers this:

	Dan Nelson
Indexed Database still slowchristopher.l.hood28 Jul
  • Re: Indexed Database still slowBrent Baisley28 Jul
    • Re: Indexed Database still slowSGreen28 Jul
  • Re: Indexed Database still slowSGreen28 Jul
    • Re: Indexed Database still slowDan Nelson28 Jul
  • Re: Indexed Database still slowEgor Egorov29 Jul
RE: Indexed Database still slowchristopher.l.hood28 Jul