Re: Speed Up QueryTime



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 ..


Relevant Pages

  • RE: Any good T-SQL quick reference recommended?
    ... The full syntax of the SELECT ... SELECT Clause ... Specifies the columns to be returned by the query. ... Specifies that duplicate rows can appear in the result set. ...
    (microsoft.public.sqlserver.programming)
  • RE: Xlocking with a select statement
    ... named query expression, order clause, update clause, lock option ... A result table or the underlying base tables are updateable if the query ... A lock can be requested for the ...
    (microsoft.public.sqlserver.programming)
  • Re: VB-ADO-SQL Server : SQL Server performs logins after some queries
    ... If you have some joins or WHERE clause in your statement, ... Also try to minimize selection of the records using WHERE ... Incase of actual action query, ... >> of queries and I've concluded that in case of an internet conection the ...
    (microsoft.public.vb.database.ado)
  • Re: update query: still having problems
    ... "Michel Walsh" wrote: ... From the User Interface, in the toolbar, or the menu, when you edit a query, ... If this is what you want, fine, else, add a WHERE clause to limit ... SELECT Department.*, sheet1.* ...
    (microsoft.public.access.queries)
  • Re: update query: still having problems
    ... "Michel Walsh" wrote: ... you should find a button that allows you to change the query "type". ... If this is what you want, fine, else, add a WHERE clause to ... SELECT Department.*, sheet1.* ...
    (microsoft.public.access.queries)