Subject | Re: [firebird-support] Re: another make my query faster question |
---|---|
Author | Arno Brinkman |
Post date | 2006-07-14T07:42:44Z |
Hi,
t.NAME CONTAINING 'after the ball') on the table TITLE is only small set of the whole table.
There can't be used an index on TITLE because your CONTAINING comparison can't use an index.
20 seconds looks very long to me, but how many products do you've in the final result?
For filtering 1 ASC-index on the NAME field is enough. Also note that FK en PK automaticly create indexes. So if you've
an FK on PRODUCT.TITLEID you don't need the index IDX_PRODUCT_TITLEID.
Doesn't the METAPHONE comparison already return all matches where 'after the ball' is part of the name? Are you sure you
need OR and not AND?
Regards,
Arno Brinkman
ABVisie
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
General database developer support:
http://www.databasedevelopmentforum.com
Firebird open source database (based on IB-OE) with many SQL-99 features:
http://www.firebirdsql.org
http://www.firebirdsql.info
Support list for Interbase and Firebird users:
firebird-support@yahoogroups.com
Nederlandse firebird nieuwsgroep:
news://newsgroups.firebirdsql.info
>> I assume that the filter on the TITLE table is very strong so iI meant the result from your condition (t.METAPHONE = METAPHONE('after the ball') OR
> force the order by using "+ 0" (assuming TitleID is
>> numeric).
>
> i'm not quite sure what you mean by the filter being very strong.
> TITLEID is INTEGER NOT NULL and the primary key.
t.NAME CONTAINING 'after the ball') on the table TITLE is only small set of the whole table.
> that query takes around 20 seconds with the OR CONTAINING conditionThe PLAN looks very good to me.
> with 99206 un-indexed reads on the TITLE table (which is also the
> number of records in the table). the PRODUCT and PRODUCT_PARTICIPANT
> tables have 112933 records, and the PARTICIPANT_NAME table has 32948
> records. the plan is...
>
> Plan:
> PLAN SORT (JOIN (T NATURAL, P INDEX (IDX_PRODUCT_TITLEID), PP INDEX
> (PK_PRODUCT_PARTICIPANT), PN INDEX (PK_PARTICIPANT_NAME)))
There can't be used an index on TITLE because your CONTAINING comparison can't use an index.
20 seconds looks very long to me, but how many products do you've in the final result?
> i originally only had a unique index on TITLE.NAME but adding anCONTAINING can't use an index thus adding more indexes has no effect.
> ascending an descending index on NAME didn't make any difference to
> the plan or the speed of the query.
For filtering 1 ASC-index on the NAME field is enough. Also note that FK en PK automaticly create indexes. So if you've
an FK on PRODUCT.TITLEID you don't need the index IDX_PRODUCT_TITLEID.
Doesn't the METAPHONE comparison already return all matches where 'after the ball' is part of the name? Are you sure you
need OR and not AND?
Regards,
Arno Brinkman
ABVisie
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
General database developer support:
http://www.databasedevelopmentforum.com
Firebird open source database (based on IB-OE) with many SQL-99 features:
http://www.firebirdsql.org
http://www.firebirdsql.info
Support list for Interbase and Firebird users:
firebird-support@yahoogroups.com
Nederlandse firebird nieuwsgroep:
news://newsgroups.firebirdsql.info