由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Database版 - SQL find distinct values in large table
相关主题
help about SQL for ACCESS一个关于T-SQL的问题
问一个SQL Server的问题请教一个SQL的问题
compare two large tables SQL (转载)ask for help with a simple query!!!
SQL select one value column for each distinct value another (转载)Help on Sql server huge table performance
SQL combine two columns from two different tables no shared (转载)Help! A cluster method in SQL
random error for CAST( MONEY AS VARCHAR)Rookie's question again
SQL问题请教: add one more column服了,这就是我们QA和DBA的水平
急问一个关于T-SQL的问题,谢谢问个SQL问题- partial outer join
相关话题的讨论汇总
话题: distinct话题: table话题: large话题: select话题: values
进入Database版参与讨论
1 (共1页)
l******9
发帖数: 579
1
I have a very large table with 1 billion rows and 12 columns, which are int,
double, varchar. I need to know the distinct values for each volume.
the table has columns :
id id_1 id_2 id_3 id_4 id_5 id_6 id_7 id_8 id_9 id_10 id_11

SELECT COUNT(distinct a.id) as num_dist_id
FROM my_large_table as a
SELECT distinct a.id
FROM my_large_table as a
It is very slow.
SELECT distinct a.id , a.id_1 , a.id_2, a.id_3, a.id_4, a.id_5, a.id_6 ...
FROM my_large_table as a
ORDER BY a.id, a.id_1, a.id_2
i need to know how many distinct values that are associated with the same
column vlue.
For example, for id = 1, how many distinct values of id_1 associated with it
.
Can I speed up the query ?
Thanks !
n*w
发帖数: 3393
2
index

int,

【在 l******9 的大作中提到】
: I have a very large table with 1 billion rows and 12 columns, which are int,
: double, varchar. I need to know the distinct values for each volume.
: the table has columns :
: id id_1 id_2 id_3 id_4 id_5 id_6 id_7 id_8 id_9 id_10 id_11
:
: SELECT COUNT(distinct a.id) as num_dist_id
: FROM my_large_table as a
: SELECT distinct a.id
: FROM my_large_table as a
: It is very slow.

1 (共1页)
进入Database版参与讨论
相关主题
问个SQL问题- partial outer joinSQL combine two columns from two different tables no shared (转载)
SQL multiply all values of a column in table (转载)random error for CAST( MONEY AS VARCHAR)
SQL fast search in a 10 million records table (转载)SQL问题请教: add one more column
SQL求助急问一个关于T-SQL的问题,谢谢
help about SQL for ACCESS一个关于T-SQL的问题
问一个SQL Server的问题请教一个SQL的问题
compare two large tables SQL (转载)ask for help with a simple query!!!
SQL select one value column for each distinct value another (转载)Help on Sql server huge table performance
相关话题的讨论汇总
话题: distinct话题: table话题: large话题: select话题: values