I have a table with 200 columns (maybe more...)
a1 a2 a3 a4 a5 ...a200
---------------------------------
1.2 2.3 4.4 5.1 6.7... 11.9
7.2 2.3 4.3 5.1 4.7... 3.9
1.9 5.3 3.3 5.1 3.7... 8.9
5.2 2.7 7.4 9.1 1.7... 2.9
I would like to compute many operations:
- SUM(every column)
- AVG(every column)
- SQRT(SUM(every column))
- POWER(SUM(every column),2)
- MIN(all columns)
- MAX(all columns)
GREATEST(SUM(one column) vs SUM(other column)) something like finding wich sum is greatest for every column:
a1 vs a2, a1 vs a3, a1 vs a4....,a1 vs a200, a2 vs a1, a2 vs a3, a4 vs a5....,a2 vs a200, ... a200 vs a1, a200vs a2, a200vs a3.....a200 vs a199
If I do a single select statement for each column,and for each operation I'd have:
SELECT
SUM(a1),...,SUM(a200),
AVG(Sum(a1)),...,AVG(Sum(a200)),
POWER(Sum(a1),2),...,POWER(Sum(a200),2),
GREATEST(SUM(a1),SUM(a2)), GREATEST(SUM(a1),SUM(a3)),...,GREATEST(SUM(a1),SUM(a200)),
GREATEST(SUM(a2),SUM(a1)), GREATEST(SUM(a2),SUM(a3)),...,GREATEST(SUM(a2),SUM(a200))....
GREATEST(SUM(a200),SUM(a1)), GREATEST(SUM(a200),SUM(a3)),...,GREATEST(SUM(a200),SUM(a199))
etc... FROM tabMultipleColumns
The problem here is when I do a query with more than 1024 possible results aka, >= 1024 columns
Is there a way to keep doing massive operations with data doing a single scan of the table, I mean avoiding doing multiple selects statements?
I am trying to use only a scan, because if the table is huge (with size of many GB's) using many selects statements to scan the same table would be expensive...
Can a tool like BCP
be used or what solution do you think开发者_高级运维 is more efficient...
if you look only for the SUM, POWER(SUM(),2) and SQRT(SUM()), there are 600
result columns... if I keep doing this operations there are more than 1024...
That's a lot of calculations. I would probably just do a periodic dump of them into another table to minimize server load. It depends on how often the query is going to be used though.
精彩评论