Hi all,
I've been tasked with creating tables used solely for displaying lists, for example: All currently available transaction types. The tables will be used in a report tool.
These tables will need to be updated on a recurring basis, so this process needs to be as efficient and robust as possible.
The database I'll be working with is HUGE! So distinct queries are pretty slow.
Currently I'm testing with a db that has approx 23M records (as of a few days ago), so it gives me an idea of how fast/slow it might be.
So I started creating a table with the one column. Temp_List_Test
Then did an insert into the table from a select distinct statement for all transaction types for a partial timeframe of the last full month 12/1 - 12/17 (5217 records).
I did a partial month so that I could validate the number of records when I get the next insert statement to work. (For the entire month of Dec, the same select distinct statement returns 6367 Records)
Then because MySQL does not allow concurrent inserts, I throw a select field from table limit 1 in between.
(Normally, the inserts won't be concurrent, so this is just something to placate MySQL)
First I tried Insert...Select Distinct...From BaseTable where the date >= '2012-12-18' and the transaction type not in (Select....From Temp_List_Test)
0 rows affected Records 0.
Then I tried Insert...Select Distinct...From BaseTable where the date >= '2012-12-18' and not exists (Select....From Temp_List_Test)
0 rows affected Records 0.
Next I tried Insert...Select Distinct...From BaseTable t1 Left Join Temp_List_Test t2 on t1.TransType = t2.TransType and t2.TransType is NULL and date >= '2012-12-18'
Bummer, lost the connection during the query...either way, it was over 11 minutes and that's not good.
Any help would be appreciated.
Thanks in advance.
Jacque
I've been tasked with creating tables used solely for displaying lists, for example: All currently available transaction types. The tables will be used in a report tool.
These tables will need to be updated on a recurring basis, so this process needs to be as efficient and robust as possible.
The database I'll be working with is HUGE! So distinct queries are pretty slow.
Currently I'm testing with a db that has approx 23M records (as of a few days ago), so it gives me an idea of how fast/slow it might be.
So I started creating a table with the one column. Temp_List_Test
Then did an insert into the table from a select distinct statement for all transaction types for a partial timeframe of the last full month 12/1 - 12/17 (5217 records).
I did a partial month so that I could validate the number of records when I get the next insert statement to work. (For the entire month of Dec, the same select distinct statement returns 6367 Records)
Then because MySQL does not allow concurrent inserts, I throw a select field from table limit 1 in between.
(Normally, the inserts won't be concurrent, so this is just something to placate MySQL)
First I tried Insert...Select Distinct...From BaseTable where the date >= '2012-12-18' and the transaction type not in (Select....From Temp_List_Test)
0 rows affected Records 0.
Then I tried Insert...Select Distinct...From BaseTable where the date >= '2012-12-18' and not exists (Select....From Temp_List_Test)
0 rows affected Records 0.
Next I tried Insert...Select Distinct...From BaseTable t1 Left Join Temp_List_Test t2 on t1.TransType = t2.TransType and t2.TransType is NULL and date >= '2012-12-18'
Bummer, lost the connection during the query...either way, it was over 11 minutes and that's not good.
Any help would be appreciated.
Thanks in advance.
Jacque