If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
My update query is very slow...need help!!
I wrote 7 update queries for updating the field startofweek and endofweek depending on the reportday, it takes more than 2 hrs to run all of them for 250000 records, do anyone knows how to run these 7 queries faster?
for all records with reportday is on SUNDAY UPDATE mastertable SET mastertable.Startofweek = [REPORTDAY], mastertable.Endofweek = [REPORTDAY]+6 WHERE (((DatePart("w",[REPORTDAY]))=1)); for all records with reportday is on MONDAY UPDATE mastertable SET mastertable.Startofweek = [REPORTDAY]-1, mastertable.Endofweek = [REPORTDAY]+5 WHERE (((DatePart("w",[REPORTDAY]))=2)); : : : for all records with reportday is on Saturday UPDATE mastertable SET mastertable.Startofweek = [REPORTDAY]-6, mastertable.Endofweek = [REPORTDAY] WHERE (((DatePart("w",[REPORTDAY]))=7)); |
#2
|
|||
|
|||
My update query is very slow...need help!!
Just a suggestion.
Make a table called weeks. Week StartDate EndDate 1 1-1-2004 1-7-2004 2 1-8-2004 1-14-2004 3 1-15-2004 1-21-2004 etc.. Then run one query UPDATE mastertable SET mastertable.Week = Weeks.Week WHERE mastertable.[Report Day] Between Weeks.[StartDate] And Weeks.[EndDate] |
#3
|
|||
|
|||
My update query is very slow...need help!!
If you have not already done so, index all of the fields
you will be searching in the table. |
#4
|
|||
|
|||
My update query is very slow...need help!!
"Tasha" ¼¶¼g©ó¶l¥ó ... Just a suggestion. Make a table called weeks. Week StartDate EndDate 1 1-1-2004 1-7-2004 2 1-8-2004 1-14-2004 3 1-15-2004 1-21-2004 etc.. Then run one query UPDATE mastertable SET mastertable.Week = Weeks.Week WHERE mastertable.[Report Day] Between Weeks.[StartDate] And Weeks.[EndDate] |
Thread Tools | |
Display Modes | |
|
|