473,385 Members | 1,409 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.

More Efficient way to Query?

ChaseCox
294 100+
I am using a form to populate a query. The query is looking at around 1.4 Million records to date, every week this will only increase. Currently when I run my query from the form via a command button, the query will take about 8-10 min to run. Is there a better way to do this? I will post the SQL of the query, and if something else is needed let me know.

Expand|Select|Wrap|Line Numbers
  1. SELECT [Generic Material].CLAIM_NBR, [Generic Material].DETAIL_NBR, [Generic Material].CLAIM_TYPE_DESCR, [Generic Material].[CLAIM DATE], [Generic Material].[SHIP DATE], [Generic Material].PROD_CODE, InStr([Forms]![Form1]![txtsee].[Text],[Prod_Code]) AS ProdCodeParam, [Generic Material].PROD_CODE_DESCR, [Generic Material].RFC_CODE, [Generic Material].PROD_GRP, [Generic Material].RFC_FAILURE_DESCR, [Generic Material].RFC_FAILURE_MAT_IND, [Generic Material].RFC_FAILURE_LBR_IND, [Generic Material].RFC_LEVEL_ONE_DESCR, [Generic Material].RFC_LEVEL_TWO_DESCR, [Generic Material].RFC_LEVEL_THREE_DESCR, [Generic Material].RFC_LEVEL_FOUR_DESCR, [Generic Material].RFC_SHORT_DESCR, [Generic Material].BU_ID, [Generic Material].PART_PART_NBR, [Generic Material].PART_DESCR, [Generic Material].SUBMIT_OFFICE_NAME, [Generic Material].PARENT_SERIAL_NBR, Mid([ORDERED_MODEL],1,38) AS [Model Number], [Generic Material].COST_CENTER, [Generic Material].ACCOUNT, [Generic Material].TASK_CODE, [Generic Material].TASK_DESCR, [Generic Material].SALES_ORDER_PRIME, [Generic Material].[DATE ENTERED], [Generic Material].[DATE APPROVED], [Generic Material].[DATE STARTED], [Generic Material].[DATE FAILED], [Generic Material].DETAIL_QTY, [Generic Material].SumOfEXP_TYPE_AMOUNT, [Generic Material].CLAIM_JOB_NAME
  2. FROM [Generic Material]
  3. WHERE ((([Generic Material].[CLAIM DATE]) Between [Forms]![Form1]![cmbcd] And [Forms]![Form1]![cmbcde]) AND (([Generic Material].[SHIP DATE]) Between [Forms]![Form1]![cmbsd] And [Forms]![Form1]![cmbed]) AND ((InStr([Forms]![Form1]![txtsee].[Text],[Prod_Code]))>0 Or (InStr([Forms]![Form1]![txtsee].[Text],[Prod_Code])) Is Null) AND (([Generic Material].RFC_LEVEL_ONE_DESCR) Like ("*" & [Forms]![Form1]![cmbrfcl1dscr] & "*")) AND (([Generic Material].RFC_SHORT_DESCR) Like ("*" & [Forms]![Form1]![cmbrfcsd] & "*")) AND (([Generic Material].PART_PART_NBR) Like ("*" & [Forms]![Form1]![cmbpn] & "*")) AND ((Mid([ORDERED_MODEL],1,38)) Like ("*" & [Forms]![Form1]![cmbm1] & [Forms]![Form1]![cmbm2] & [Forms]![Form1]![cmbm3] & [Forms]![Form1]![cmbm4] & [Forms]![Form1]![cmbm5] & [Forms]![Form1]![cmbm6] & [Forms]![Form1]![cmbm7] & [Forms]![Form1]![cmbm8] & [Forms]![Form1]![cmbm9] & [Forms]![Form1]![cmbm10] & [Forms]![Form1]![cmbm11] & [Forms]![Form1]![cmbm12] & [Forms]![Form1]![cmbm13] & [Forms]![Form1]![cmbm14] & [Forms]![Form1]![cmbm15] & [Forms]![Form1]![cmbm16] & [Forms]![Form1]![cmbm17] & [Forms]![Form1]![cmbm18] & [Forms]![Form1]![cmbm19] & [Forms]![Form1]![cmbm20] & [Forms]![Form1]![cmbm21] & [Forms]![Form1]![cmbm22] & [Forms]![Form1]![cmbm23] & [Forms]![Form1]![cmbm24] & [Forms]![Form1]![cmbm25] & [Forms]![Form1]![cmbm26] & [Forms]![Form1]![cmbm27] & [Forms]![Form1]![cmbm28] & [Forms]![Form1]![cmbm29] & [Forms]![Form1]![cmbm30] & [Forms]![Form1]![31] & [Forms]![Form1]![32] & [Forms]![Form1]![33] & [Forms]![Form1]![34] & [Forms]![Form1]![35] & [Forms]![Form1]![36] & [Forms]![Form1]![37] & [Forms]![Form1]![38] & "*")) AND (([Generic Material].TASK_CODE) Like ("*" & [Forms]![Form1]![cmbtc] & "*")) AND (([Generic Material].TASK_DESCR) Like ("*" & [Forms]![Form1]![cmbtd] & "*")) AND (([Generic Material].[DATE STARTED]) Between [Forms]![Form1]![cmcsd1] And [Forms]![Form1]![cmcsd2]) AND (([Generic Material].[DATE FAILED]) Between [Forms]![Form1]![cmcfd1] And [Forms]![Form1]![cmbfd2]));
  4.  
Jan 16 '07 #1
5 1587
ChaseCox
294 100+
There has been an indepth discussion of my DB so far here, http://www.thescripts.com/forum/thre...ml#post2312376
Jan 16 '07 #2
MMcCarthy
14,534 Expert Mod 8TB
I'm a little concerned about your brackets. Access will add further brackets but can you copy and paste this in exactly as it is and see if there is any improvement.

Mary

Expand|Select|Wrap|Line Numbers
  1. SELECT CLAIM_NBR, DETAIL_NBR, CLAIM_TYPE_DESCR, 
  2. [CLAIM DATE], [SHIP DATE], PROD_CODE, 
  3. InStr([Forms]![Form1]![txtsee].[Text],[Prod_Code]) AS ProdCodeParam, 
  4. PROD_CODE_DESCR, RFC_CODE, PROD_GRP, 
  5. RFC_FAILURE_DESCR, RFC_FAILURE_MAT_IND, 
  6. RFC_FAILURE_LBR_IND,  RFC_LEVEL_ONE_DESCR, 
  7. RFC_LEVEL_TWO_DESCR, RFC_LEVEL_THREE_DESCR, 
  8. RFC_LEVEL_FOUR_DESCR, RFC_SHORT_DESCR, BU_ID, 
  9. PART_PART_NBR, PART_DESCR, SUBMIT_OFFICE_NAME, 
  10. PARENT_SERIAL_NBR, 
  11. Mid([ORDERED_MODEL],1,38) AS [Model Number], 
  12. COST_CENTER, ACCOUNT, TASK_CODE, TASK_DESCR, 
  13. SALES_ORDER_PRIME, [DATE ENTERED], [DATE APPROVED], 
  14. [DATE STARTED], [DATE FAILED], DETAIL_QTY, 
  15. SumOfEXP_TYPE_AMOUNT, CLAIM_JOB_NAME
  16. FROM [Generic Material]
  17. WHERE ([CLAIM DATE] Between [Forms]![Form1]![cmbcd] And [Forms]![Form1]![cmbcde]) 
  18. AND ([SHIP DATE] Between [Forms]![Form1]![cmbsd] And [Forms]![Form1]![cmbed]) 
  19. AND (InStr([Forms]![Form1]![txtsee].[Text],[Prod_Code])>0 Or  InStr([Forms]![Form1]![txtsee].[Text],[Prod_Code]) Is Null) 
  20. AND (RFC_LEVEL_ONE_DESCR 
  21. Like '*' & [Forms]![Form1]![cmbrfcl1dscr] & '*') 
  22. AND (RFC_SHORT_DESCR) 
  23. Like '*' & [Forms]![Form1]![cmbrfcsd] & '*') 
  24. AND (PART_PART_NBR Like '*' & [Forms]![Form1]![cmbpn] & '*') 
  25. AND (Mid([ORDERED_MODEL],1,38) 
  26. Like '*' & [Forms]![Form1]![cmbm1] & 
  27. [Forms]![Form1]![cmbm2] & [Forms]![Form1]![cmbm3] & [Forms]![Form1]![cmbm4] & [Forms]![Form1]![cmbm5] & [Forms]![Form1]![cmbm6] & [Forms]![Form1]![cmbm7] & [Forms]![Form1]![cmbm8] & [Forms]![Form1]![cmbm9] & [Forms]![Form1]![cmbm10] & [Forms]![Form1]![cmbm11] & [Forms]![Form1]![cmbm12] & [Forms]![Form1]![cmbm13] & [Forms]![Form1]![cmbm14] & [Forms]![Form1]![cmbm15] & [Forms]![Form1]![cmbm16] & [Forms]![Form1]![cmbm17] & [Forms]![Form1]![cmbm18] & [Forms]![Form1]![cmbm19] & [Forms]![Form1]![cmbm20] & [Forms]![Form1]![cmbm21] & [Forms]![Form1]![cmbm22] & [Forms]![Form1]![cmbm23] & [Forms]![Form1]![cmbm24] & [Forms]![Form1]![cmbm25] & [Forms]![Form1]![cmbm26] & [Forms]![Form1]![cmbm27] & [Forms]![Form1]![cmbm28] & [Forms]![Form1]![cmbm29] & [Forms]![Form1]![cmbm30] & [Forms]![Form1]![31] & [Forms]![Form1]![32] & [Forms]![Form1]![33] & [Forms]![Form1]![34] & [Forms]![Form1]![35] & [Forms]![Form1]![36] & [Forms]![Form1]![37] & [Forms]![Form1]![38] & '*') 
  28. AND (TASK_CODE Like '*' & [Forms]![Form1]![cmbtc] & '*') 
  29. AND (TASK_DESCR Like '*' & [Forms]![Form1]![cmbtd] & '*') 
  30. AND ([DATE STARTED] Between [Forms]![Form1]![cmcsd1] And  [Forms]![Form1]![cmcsd2])
  31. AND ([DATE FAILED] Between [Forms]![Form1]![cmcfd1] And [Forms]![Form1]![cmbfd2]);
  32.  
Jan 16 '07 #3
NeoPa
32,556 Expert Mod 16PB
There has been an indepth discussion of my DB so far here, http://www.thescripts.com/forum/thre...ml#post2312376
...Including a copy of the structure of the database attached - without any data though (Wanted to register with this thread).
Jan 16 '07 #4
ChaseCox
294 100+
That worked very well, thank you for your help.
Jan 18 '07 #5
MMcCarthy
14,534 Expert Mod 8TB
That worked very well, thank you for your help.
No problem.

Mary
Jan 18 '07 #6

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

Similar topics

8
by: Trev | last post by:
Which is more efficient: Select * from table1 where id in (select id from table2) or Select * from table1 where exists(select * from table2 where table2.id=table1.id)
4
by: Koen | last post by:
Hi all, At work I created a database which is really helpful. The database is used by approx 15 users. Everything worked great, until I added some 'scoreboard' forms and reports. I get the...
4
by: Bob Alston | last post by:
Some more, rather specific Access performance questions. IN a split front-end & back-end Access/Jet ONLY LAN situation, and with all query criteria fields and join fields indexed: 1. Is is...
3
by: Brian Wotherspoon | last post by:
I have a table with data that is refreshed regularly but I still need to store the old data. I have created a seperate table with a foreign key to the table and the date on which it was replaced. ...
13
by: CJM | last post by:
I have an ASP/ADO application querying an SQL Server DB. I want know the most efficient way to determine if more than one row is returned from a query. If more than one row is returned, the user...
20
by: laredotornado | last post by:
Hi, I'm using PHP 4.3. I have 15 pages in which I need to take the content of the BODY and put it in a little table ... <table> <tr><td colspan="3"><img src="header.gif"></td></tr> <tr>...
2
by: teser3 | last post by:
I would like to know if it is possible to do a pattern match or better way to condense my below query in Access 2003. Basically I need to query the average with all fields in TableOne that end...
4
by: Mark | last post by:
Hey folks, I'm looking at making the following query more efficient potentially using the ranking functions and I'd like some advice from the gurus. The purpose of the following is to have a...
3
by: Ken Fine | last post by:
This is a question that someone familiar with ASP.NET and ADO.NET DataSets and DataTables should be able to answer fairly easily. The basic question is how I can efficiently match data from one...
1
by: joshai | last post by:
Hi, I'm pretty new to the php/mysql world and am building an article database for a website with multiple content types. I have an entry screen built that allows the site owner to enter articles,...
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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...
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.