Re: Speed Up QueryTime
- From: "Arnie Rowland" <arnie@xxxxxxxx>
- Date: Mon, 26 Jun 2006 07:49:12 -0700
You do not want to use 'LIKE '%". That causes the server to have to needlessly read each and every value.Also, you SHOULD list each column you want to retreive. Using SELECT * may cause you undesired problems in the future.
Here are a couple of choices:
1. NO where clause
SELECT
Column1
, Column2
, Column3
, etc
FROM MyTable
2. Where clause with the option to search for a value or get all rows if there is no value.
SELECT
Column1
, Column2
, Column3
, etc
FROM MyTable
WHERE SearchColumn = coalesce( @MySearchField, SearchColumn)
In the second example, you can pass in a search parameter @MySearchField, and if it is not NULL, it will be used to retreive matching data. If it is NULL, then all rows will be returned (subject to other search criteria, of course.)
--
Arnie Rowland, YACE*
"To be successful, your heart must accompany your knowledge."
*Yet Another Certification Exam
"Nishant Giri" <NishantGiri@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:57AABBF6-3FCC-405E-BF99-1FD131EF2A81@xxxxxxxxxxxxxxxx
Hi i am using sql 2000 . i am searching all the records into the database,
for this i have used the 'Like %' in my query ..For Example
Select * from table1
WHERE Col1 Like '%'
But the response time of this query is very high . How can i reducde the
responsetime of the query , Is there any way to avoid this 'Like %' Operator
so that i can search all the records and also reduce the response time ..
- Prev by Date: Re: Missing name type for name entity
- Next by Date: Re: distinct with all the columns
- Previous by thread: Re: date format
- Index(es):
Relevant Pages
|
|