Subject Re: Bad query optimisation on the MAC?
Author phil_hhn
--- In firebird-support@yahoogroups.com, Svein Erling Tysvær
<svein.erling.tysvaer@k...> wrote:
>
> Hi Phil, I'm answering simply because no-one else seems to have
picked
> it up...
>
> Are you sure that 0.6 seconds versus 5 seconds is the time it takes
to
> transfer all records to the client and not just the first few so
that
> the screen gets filled (i.e. do you read to end-of-file)?

Wouldn't you know it - I decide to programatically get you the speeds
today, and the MACs are running faster! But still much slower than
windows.

From Windows, connecting to Firebird running on Windows:
Running the query: 640ms.
Iterating through ALL results: 16ms (negligible)

From Windows, connecting to Firebird running on MAC:
Running the query: 3141ms first time, ~2095ms thereafter.
Iterating through ALL results: 15ms (negligible)

From Windows, connecting to Firebird running on another MAC
(supposedly faster), I think with firebird 1.5.0:
Running the query: 2313ms
Iterating through ALL results: 16ms



> Do you get the same performance if you change from LIKE to STARTING?

I've never used STARTING - is that a standard SQL keyword? Regardless,
in the final code we will need to search on magic%, %magic, or %magic%
(the last one is probably all we'll use).

> Or, more
> basic, exactly how are you selecting the records (which
> program/components)???

I do not understand your question - you mean in Java? If so, the tests
described are executed via java.sql.Statement object, calling
executeQuery and processing the returned ResultSet.

> Does Windows and Mac have the same memory
> available?

You mean available to Firebird? Both on windows and the MAC the
settings are the default (since we haven't changed them). If you are
talking of the physical memory on both machines, then that is
something completely different and like comparing apples and oranges.

> > Then this afternoon I found something else weird.
> >
> > I replaced "select a.title from TableA..." with "select * from
> > TableA..." and the query only takes 1.5 - 2.0 seconds!! That's a
> > huge improvement, but it doesn't make sense. How could selecting
all
> > columns from a table be faster than just selecting one of them?
>
> I suppose this could make sense if the 5 seconds were the time
> neccessary to transfer all records, whereas the 2 seconds were only
> the first few records...

No, the same number of records are read in each instance.

> I'm sorry to say that I know nothing about MACs. In Windows, I
would
> recommend you to run IB_SQL and read the plan, but I know nothing
> about neither MAC nor isql (which I expect to be able to produce a
> plan). In general LIKE does not use an index, whereas STARTING does
> (the exception being LIKE <constant>, where the optimizer at the
time
> of prepare can see that the first few characters of the string is
> known and as such can benefit from using an index).

Thanks, will look into whether STARTING is useful to us.