dbTalk Databases Forums  

Large list in select ... where ... in

comp.databases.sybase comp.databases.sybase


Discuss Large list in select ... where ... in in the comp.databases.sybase forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Nina G.
 
Posts: n/a

Default Large list in select ... where ... in - 06-20-2007 , 05:59 PM






I need to run a simple query like

select fee from charges where code in ('value1', 'value2', ..., 'valueN')

where values are 5 character strings. Is there anything bad in having
between 500 and 1000 values in the value list?

Thank you,

Eliyahu





Reply With Quote
  #2  
Old   
amit
 
Posts: n/a

Default Re: Large list in select ... where ... in - 06-21-2007 , 09:57 AM






On Jun 21, 3:59 am, "Nina G." <nospam@nospam> wrote:
Quote:
I need to run a simple query like

select fee from charges where code in ('value1', 'value2', ..., 'valueN')

where values are 5 character strings. Is there anything bad in having
between 500 and 1000 values in the value list?

Thank you,

Eliyahu
500-1000 values would slow down the performance, but you can use it.
The limit for 'in' clause is 1024 so
make sure the it doesn't exceed that.

Thanks
Amit



Reply With Quote
  #3  
Old   
SalmonTraining
 
Posts: n/a

Default Re: Large list in select ... where ... in - 06-21-2007 , 02:47 PM



Amit is correct.

If you think you're going to exceed the limits and are looking for an
alternative design, you may get better performance by loading in your
values into a temp table, and then using the "where exists" syntax
(which ensures the query stops once it finds a value).

John Winter
www.SalmonTraining.com/SybaseZone


Reply With Quote
  #4  
Old   
Eliyahu G.
 
Posts: n/a

Default Re: Large list in select ... where ... in - 06-21-2007 , 04:40 PM



Thank you Amit and John.

"SalmonTraining" <nospam (AT) salmontraining (DOT) com> wrote

Quote:
Amit is correct.

If you think you're going to exceed the limits and are looking for an
alternative design, you may get better performance by loading in your
values into a temp table, and then using the "where exists" syntax
(which ensures the query stops once it finds a value).

John Winter
www.SalmonTraining.com/SybaseZone




Reply With Quote
  #5  
Old   
Michael Peppler
 
Posts: n/a

Default Re: Large list in select ... where ... in - 05-21-2009 , 12:42 AM



On Thu, 21 Jun 2007 01:59:43 +0200, Nina G. wrote:

Quote:
I need to run a simple query like

select fee from charges where code in ('value1', 'value2', ..., 'valueN')

where values are 5 character strings. Is there anything bad in having
between 500 and 1000 values in the value list?

I'm guessing that you are generating the IN list programmatically. Why not
stuff that data into a temp table, and then join with the main table ?

Michael
--
Michael Peppler - Peppler Consulting SaRL
mpeppler (AT) peppler (DOT) org - http://www.peppler.org
Sybase DBA/Developer - TeamSybase: http://www.teamsybase.com
Sybase on Linux FAQ - http://www.peppler.org/FAQ/linux.html



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.