Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 8 of 8 total
Thread Too slow query with contains and IN operator
Thu, Jul 16 2009 3:06 PMPermanent Link

Yavuz Ozdemir
Hi,

I tested DBISAM vs ElevateDb for TextSearch operation.

Please apply below steps:
1. Create a word generator using ids_wg.txt in Delphi 2009
2. Create a session and database and run below statament:
  CREATE WORD GENERATOR "MyWord"
  MODULE "MyWordGen"
  description 'RxMediaPharma Word Generator'
2. Create db using ids_db.sql
3. Run ids_insert with 10000 param
4. Run above statement:
select * from ids
where
(id in (select z.id from idg z where z.g collate trk CONTAINS '0206080301*'))

This query too slow (57 sec). DBISAM run this query less than 1 sec.

Have you any suggestion?



Attachments: ids.zip
Fri, Jul 17 2009 11:10 AMPermanent Link

Yavuz Ozdemir
<<Yavuz Ozdemir wrote:

Hi,

I tested DBISAM vs ElevateDb for TextSearch operation.

Please apply below steps:
1. Create a word generator using ids_wg.txt in Delphi 2009
2. Create a session and database and run below statament:
  CREATE WORD GENERATOR "MyWord"
  MODULE "MyWordGen"
  description 'RxMediaPharma Word Generator'
2. Create db using ids_db.sql
3. Run ids_insert with 10000 param
4. Run above statement:
select * from ids
where
(id in (select z.id from idg z where z.g collate trk CONTAINS '0206080301*'))

This query too slow (57 sec). DBISAM run this query less than 1 sec.

Have you any suggestion?
>>

i try below sql:

select id from ids
intersect
select z.id from idg z where z.g collate trk CONTAINS '0206080301*'

Executin time : 0.9 sec
Fri, Jul 17 2009 12:57 PMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Yavuz


What happens if you try it without the collate?

Roy Lambert
Fri, Jul 17 2009 2:13 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Yavuz,

<< 4. Run above statement:
select * from ids
where
(id in (select z.id from idg z where z.g collate trk CONTAINS
'0206080301*')) >>

Are you using RequestSensitive=True or RequestSensitive=False when you
execute the query ?

--
Tim Young
Elevate Software
www.elevatesoft.com

Sat, Jul 18 2009 4:04 AMPermanent Link

Yavuz Ozdemir
Tim,

RequestSensitive=False

test results:

'02*'  : 0.875 sec
'0206*' : 0453 sec

'020608*' : 4.61 sec
'02060803*' : 21.234 sec

Yavuz
Sat, Jul 18 2009 6:56 AMPermanent Link

Yavuz Ozdemir
Sorry,

The first command (with IN operator) and the second command (with INTERSECT) not identical.

I must use the first command. But its is too slow.

Yavuz
Mon, Jul 20 2009 10:05 AMPermanent Link

Yavuz Ozdemir
Tim,

please redesign idg table:
1. column order  :G, id
2. primary index :G, id

and run below statement:
select * from ids
where
(id in (select z.id from idg z where z.g CONTAINS '0206080301*'))

Elapsed  time is appr. 0.1 sec.

does  the elevatedb use only primary index for the statement?
Mon, Jul 20 2009 3:09 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Yavuz,

<< RequestSensitive=False >>

Okay, the issue is that the IN operator is a brute-force operator, i.e. it
results in the SELECT for the IN being searched once for every row in the
outer query.  This version of the query accomplishes the same thing much
faster:

select ids.* from ids
inner join idg z on ids.id=z.id
where z.g collate trk CONTAINS '0206080301*'

--
Tim Young
Elevate Software
www.elevatesoft.com

Image