473,385 Members | 1,317 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

performance is poor in this query where this table has got millions of records

5
query:

SELECT
COUNT(*)
FROM
dwdbo.FNL_DW_COM_ACCT_D a
WHERE
a.ACCT_REPORT_DT = '30/jun/2011' --v_report_dt
AND
(INSTR(TO_CHAR(a.ods_acct_id), '888') > 0 --v_search_attr
OR INSTR(a.acct_nm, '888') > 0
OR INSTR(a.client_id, '888') > 0
OR INSTR(a.apace_acct_nbr, '888') > 0
OR INSTR(a.psr_id, '888') > 0
OR INSTR(a.pms_id, '888') > 0
OR INSTR(a.camra_id, '888') > 0
OR INSTR(a.reporting_id, '888') > 0
OR INSTR(a.regent_id, '888')> 0
OR INSTR(a.epace_acct_nbr, '888')> 0 )
Nov 4 '11 #1
3 1888
Rabbit
12,516 Expert Mod 8TB
Make sure you have the appropriate indexes. Also, using like might produce a quicker result. It may even be quicker to split out the individual where conditions and use a union.
Nov 4 '11 #2
bhooma
5
Like clause gave me the same result as Instr. i have 2 indexs on this table ie .ods_acct_id anf report_dt where its been used first in where clause.

can u pls give some some solution by rewriting this query
Nov 11 '11 #3
Rabbit
12,516 Expert Mod 8TB
You're using more fields in your where clause than you have indexes on. Also, there's no way to optimize a query without knowing the query plan and the environment in which it is run.
Nov 14 '11 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Bernie | last post by:
Greetings, I have 3 servers all running SQL Server 2000 - 8.00.818. Lets call them parent, child1, and child 2. On parent, I create a view called item as follows: CREATE view Item as...
1
by: rsarath | last post by:
Hello, I have the following setup and I would appreciate any help in improving the performance of the query. BigTable: Column1 (indexed) Column2 (indexed) Column3 (no index) Column4 (no...
4
by: shumaker | last post by:
I'm wondering how/why this query works. Trying to get my head wrapped around SQL. Basically the Query deletes from the Import table all records that are already in FooStrings so that when I do an...
8
by: Együd Csaba | last post by:
Hi All, how can I improve the query performance in the following situation: I have a big (4.5+ million rows) table. One query takes approx. 9 sec to finish resulting ~10000 rows. But if I run...
1
by: Megan | last post by:
Hi everybody- For some reason, I cannot get this query to work. I have 2 identical tables. One table is new, the other is old. I want to be able to tell which records in the newer table are...
2
by: MLH | last post by:
I had a table (tblReturnReceipts) with 47 records and I wanted 18 of its records deleted. So I thought I would be smart and make another table (a temporary junk table) named BadRRIDs and use it in...
8
by: Gem | last post by:
Hi I'm struggling with a query returning too many records. I have 3 related tables. tblPatients tblOperations tblTargets Each patient in tblPatients can have more than one operation...
5
by: Massimo | last post by:
The iussue: Sql 2K I have to keep in the database the data from the last 3 months. Every day I have to load 2 millions records in the database. So every day I have to export (in an other...
0
by: anchiang | last post by:
Hi All, I need to do bulk processing several tables that contain few millions records to generate report. there is 4 tables say A, B, C, D A is the transaction table, I need to retrieve data...
1
by: doll | last post by:
hi all i need to write a query to copy the records from existing table to new table...my existing table name is persons and the fields are name, salary,id,age..i need to copy these to...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.