[firebird-support] Re: No index used for join on 'starting with'

2012-04-19 Thread Dmitry Yemanov
19.04.2012 20:30, Rick Debay wrote: I will, after we migrate to FB 2.5.x. Right now we're still on 1.5.6. This may explain your plan issue. I don't expect you facing it again after migration. Dmitry

Re: [firebird-support] Re: No index used for join on 'starting with'

2012-04-12 Thread Michael Ludwig
unordained schrieb am 11.04.2012 um 15:18 (-0500): I once worked on medical software (with Firebird!) and we had to deal with ICD-9 and CPT-4 codes. The coding mechanism is somewhat hierarchical: code 201 might mean something, and 201.1 might be more specific, and 201.12 might be even *more*

[firebird-support] Re: No index used for join on 'starting with'

2012-04-11 Thread Dmitry Yemanov
11.04.2012 1:49, unordained wrote: select 1 from bt_dchronexpl inner join bt_ref on bt_ref.file_num = bt_dchronexpl.filenumber; -- PLAN JOIN (BT_DCHRONEXPL NATURAL, BT_REF INDEX (IX_BT_REF_FILE_NUM_ASC)) -- so it CAN use an index, but why not both? just the size imbalance? It's impossible to

Re: [firebird-support] Re: No index used for join on 'starting with'

2012-04-11 Thread unordained
-- Original Message --- From: Dmitry Yemanov dim...@users.sourceforge.net select 1 from bt_dchronexpl inner join bt_ref on bt_ref.file_num = bt_dchronexpl.filenumber; -- PLAN JOIN (BT_DCHRONEXPL NATURAL, BT_REF INDEX (IX_BT_REF_FILE_NUM_ASC)) -- so it CAN use an index, but

[firebird-support] Re: No index used for join on 'starting with'

2012-04-11 Thread Dmitry Yemanov
11.04.2012 19:09, unordained wrote: a) for every row in A (regardless of order), do a PK lookup in B [which, ignoring index-caching, or some implementation tweak to remember where in the index you last were as a best-guess for the next lookup, is wasteful, as it would restart from the root

Re: [firebird-support] Re: No index used for join on 'starting with'

2012-04-11 Thread Ann Harrison
Dmitry, Still, this doesn't explain why I do see it sometimes using an index to support a starts-with join, and he doesn't. I can hardly guess without a test case. Way back in the message chain was an example. If I understood it correctly, it was something like this: create table core

[firebird-support] Re: No index used for join on 'starting with'

2012-04-11 Thread Dmitry Yemanov
Ann, Way back in the message chain was an example. I remember the example, but IIRC there was no DDL provided. And I recall that the FB version wasn't specified either. My crystal ball tends to fail in such unclear conditions. create table core (coreName varchar(30), coreCode char (2));

Re: [firebird-support] Re: No index used for join on 'starting with'

2012-04-11 Thread Ann Harrison
Dmitry, As expected, it does use the index. And if this test does use the index, then you'll need a test with ddl and possibly data from the original author. This is what I'm asking for :-) Right. And perhaps the author can think about the differences between the case that appears not

Re: [firebird-support] Re: No index used for join on 'starting with'

2012-04-11 Thread unordained
-- Original Message --- From: Ann Harrison aharri...@ibphoenix.com And what part of relational theory allows partial matches on keys. Ann --- End of Original Message --- H. Codd might disagree with the incomplete normalization of his base tables, but relational

Re: [firebird-support] Re: No index used for join on 'starting with'

2012-04-11 Thread unordained
-- Original Message --- From: Dmitry Yemanov dim...@users.sourceforge.net This is known as a nested loop join. And restart from the root costs just a couple of page reads that are likely to be satisfied using the cache. Not something really wasteful. 2) Streams are read in