sql server - SQL performance of count with where clause vs select -



sql server - SQL performance of count with where clause vs select -

i updating code (which did not write) first runs query such as

select count(*) dbo.app_person person person._pk > 0 , person.last_name 'lname%' , person.first_name 'fname%' , person._pk in (select _pk dbo.app_personview )

if resulting count not large, later runs much same query, select person._pk in place of select count(*). otherwise user told refine set of selections , seek again.

(the fields checked, , values compare to, user input.)

is there reason not run sec form , @ size of result, don't need run query twice? select count(*) much faster select person._pk (the primary key)?

this run under sqlserver 2005 or later, 2008 or later. table large.

yes, there reason not run sec form , @ size of result: can't get size of result without scanning through whole result set.

you process results if there few plenty until there prove many, if processing expensive that's not improve option. unless has proven bottleneck system, have improve things seek improve it.

sql-server performance sql-server-2008 count

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -