列出交叉口性能這是一個
所有JSL巫師的問題。
我有文字
我需要以不同方式分組的數據。
風格=“”>
我的表看起來像這樣:
style =“font-weight:bold; text-decoration:underline; font-family:monospace;”>我的
價值類別1
第2類第3類
style =“font-family:monospace;”>
AA
1
1
0
style =“font-family:monospace;”>
BB
0
1
0
style =“font-family:monospace;”>
CC
1
0
0
style =“font-family:monospace;”>
DD
0
1
0
style =“font-family:monospace;”>
EE
1
0
0
style =“font-family:monospace;”>
FF
0
0
0
style =“font-family:monospace;”>
AA
1
1
0
style =“font-family:monospace;”>
BB
0
1
0
style =“font-family:monospace;”>
GG
0
0
0
style =“font-family:monospace;”>
HH
0
0
1
style =“font-family:monospace;”>
MM
0
1
1
類別
列允許我以不同的方式對數據進行分組。
風格=“”> 該
這個例子的類別來自
以下列表:
style =“font-size:10pt; font-family:”Courier New“; color:black;”> Category
1
style =“font-size:10pt; font-family:”Courier New“; color:navy;”> =
style =“font-size:10pt; font-family:”Courier New“; color:black;”>
{
style =“font-size:10pt; font-family:”Courier New“; color:purple;”>“AA”
style =“font-size:10pt; font-family:”Courier New“; color:navy;”>,
style =“font-size:10pt; font-family:”Courier New“; color:black;”>
style =“font-size:10pt; font-family:”Courier New“; color:purple;”>“CC”
style =“font-size:10pt; font-family:”Courier New“; color:navy;”>,
style =“font-size:10pt; font-family:”Courier New“; color:black;”>
style =“font-size:10pt; font-family:”Courier New“; color:purple;”>“EE”
style =“font-size:10pt; font-family:”Courier New“;顏色:黑色;”>}
style =“font-size:10pt; font-family:”Courier New“; color:navy;”>;
style =“font-size:10pt; font-family:”Courier New“; color:black;”>
style =“font-size:10pt; font-family:”Courier New“; color:black;”> Category
2
style =“font-size:10pt; font-family:”Courier New“; color:navy;”> =
style =“font-size:10pt; font-family:”Courier New“; color:black;”>
{
style =“font-size:10pt; font-family:”Courier New“; color:purple;”>“AA”
style =“font-size:10pt; font-family:”Courier New“; color:navy;”>,
style =“font-size:10pt; font-family:”Courier New“; color:black;”>
style =“font-size:10pt; font-family:”Courier New“; color:purple;”>“BB”
style =“font-size:10pt; font-family:”Courier New“; color:navy;”>,
style =“font-size:10pt; font-family:”Courier New“; color:black;”>
style =“font-size:10pt; font-family:”Courier New“; color:purple;”>“DD”
style =“font-size:10pt; font-family:”Courier New“; color:navy;”>,
style =“font-size:10pt; font-family:”Courier New“; color:black;”>
style =“font-size:10pt; font-family:”Courier New“;顏色:紫色;”>“MM”
style =“font-size:10pt; font-family:”Courier New“;顏色:黑色;”>}
style =“font-size:10pt; font-family:”Courier New“; color:navy;”>;
style =“font-size:10pt; font-family:”Courier New“; color:black;”>
style =“font-size:10pt; line-height:115%; font-family:”Courier New“;顏色:黑色;”>類別
3
style =“font-size:10pt; line-height:115%; font-family:”Courier New“; color:navy;”> =
style =“font-size:10pt; line-height:115%; font-family:”Courier New“;顏色:黑色;”>
{
style =“font-size:10pt; line-height:115%; font-family:”Courier New“; color:purple;”>“KK”
style =“font-size:10pt; line-height:115%; font-family:”Courier New“; color:navy;”>,
style =“font-size:10pt; line-height:115%; font-family:”Courier New“;顏色:黑色;”>
style =“font-size:10pt; line-height:115%; font-family:”Courier New“; color:purple;”>“MM”
style =“font-size:10pt; line-height:115%; font-family:”Courier New“; color:black;”>}
style =“font-size:10pt; line-height:115%; font-family:”Courier New“; color:navy;”>;
如果你是
想知道為什麼我不只是添加一個類別列,
這是因為可以
在類別列表中重疊。
因此,我
每個類別需要一個單獨的列。
如果是一個值
在裡面 myvalue的
列匹配a
類別列表中的值,則類別列為1,否則為1
是0。
這使我能夠快速執行數據的單獨分析
匹配每個類別。
我的問題
是計算類別列時的性能之一。
風格=“”> 它的
小桌子也不錯(10,000行,3
類別,小類別列表)。
風格=“”>
然而它陷入了困境
對於較大的數據集(300,000行,200
類別,大類別列表)。
風格=“”> 一些
類別列表可能非常大(2000個值)。
基本上我
需要一種快速的方法來做一些列表之間的數據交集
在裡面 myvalue的
列和每個中的數據
類別清單。
這很簡單
例子,但它說明了這個概念。
這是
邏輯我用於一個類別。
風格=“”> 該
能夠在列表和列之間找到匹配項
style =“”> SELECT WHERE
是非常強大的。
如果可以以某種方式加速
我很想知道怎麼做!
style =“font-size:10pt; font-family:”Courier New“; color:black;”> one_category
style =“font-size:10pt; font-family:”Courier New“; color:navy;”> =
style =“font-size:10pt; font-family:”Courier New“; color:black;”>
style =“font-size:10pt; font-family:”Courier New“; color:purple;”>“Category
1“
style =“font-size:10pt; font-family:”Courier New“; color:navy;”>;
style =“font-size:10pt; font-family:”Courier New“; color:black;”>
style =“font-size:10pt; font-family:”Courier New“; color:black;”> category_list
style =“font-size:10pt; font-family:”Courier New“; color:navy;”> =
style =“font-size:10pt; font-family:”Courier New“; color:black;”>
{
style =“font-size:10pt; font-family:”Courier New“; color:purple;”>“AA”
style =“font-size:10pt; font-family:”Courier New“; color:navy;”>,
style =“font-size:10pt; font-family:”Courier New“; color:black;”>
style =“font-size:10pt; font-family:”Courier New“; color:purple;”>“CC”
style =“font-size:10pt; font-family:”Courier New“; color:navy;”>,
style =“font-size:10pt; font-family:”Courier New“; color:black;”>
style =“font-size:10pt; font-family:”Courier New“; color:purple;”>“EE”
style =“font-size:10pt; font-family:”Courier New“;顏色:黑色;”>}
style =“font-size:10pt; font-family:”Courier New“; color:black;”>
style =“font-size:10pt; font-family:”Courier New“; color:black;”>
style =“font-size:10pt; font-family:”Courier New“; color:black;”> nr
style =“font-size:10pt; font-family:”Courier New“; color:navy;”> =
style =“font-size:10pt; font-family:”Courier New“; color:black;”>
style =“font-size:10pt; font-family:”Courier New“; color:rgb(0,0,221);”> nrows
style =“font-size:10pt; font-family:”Courier New“; color:black;”>(
style =“font-size:10pt; font-family:”Courier New“; color:black;”> dt )
style =“font-size:10pt; font-family:”Courier New“; color:navy;”>;
style =“font-size:10pt; font-family:”Courier New“; color:black;”>
style =“font-size:10pt; font-family:”Courier New“; color:black;”> col_zeroes
style =“font-size:10pt; font-family:”Courier New“; color:navy;”> =
style =“font-size:10pt; font-family:”Courier New“; color:black;”>
style =“font-size:10pt; font-family:”Courier New“;顏色:rgb(0,0,221);”> j
style =“font-size:10pt; font-family:”Courier New“; color:black;”>(
style =“font-size:10pt; font-family:”Courier New“; color:black;”> nr
style =“font-size:10pt; font-family:”Courier New“; color:navy;”>,
style =“font-size:10pt; font-family:”Courier New“; color:black;”>
style =“font-size:10pt; font-family:”Courier New“; color:teal;”> 1
style =“font-size:10pt; font-family:”Courier New“; color:navy;”>,
style =“font-size:10pt; font-family:”Courier New“; color:black;”>
style =“font-size:10pt; font-family:”Courier New“; color:teal;”> 0
style =“font-size:10pt; font-family:”Courier New“; color:black;”>)
style =“font-size:10pt; font-family:”Courier New“; color:navy;”>;
style =“font-size:10pt; font-family:”Courier New“; color:black;”>
style =“font-size:10pt; font-family:”Courier New“; color:black;”>
style =“font-size:10pt; font-family:”Courier New“; color:green;”> //
添加類別列
style =“font-size:10pt; font-family:”Courier New“; color:black;”>
style =“font-size:10pt; font-family:”Courier New“; color:black;”> dt
style =“font-size:10pt; font-family:”Courier New“; color:navy;”> <<
style =“font-size:10pt; font-family:”Courier New“; color:black;”>
style =“font-size:10pt; font-family:”Courier New“; color:rgb(0,0,221);”> new
柱
style =“font-size:10pt; font-family:”Courier New“; color:black;”>(
style =“font-size:10pt; font-family:”Courier New“; color:black;”> one_category
style =“font-size:10pt; font-family:”Courier New“; color:navy;”>,
style =“font-size:10pt; font-family:”Courier New“; color:black;”>
數字 )
style =“font-size:10pt; font-family:”Courier New“; color:navy;”>;
style =“font-size:10pt; font-family:”Courier New“; color:black;”>
style =“font-size:10pt; font-family:”Courier New“;顏色:rgb(0,0,221);”>列
style =“font-size:10pt; font-family:”Courier New“; color:black;”>(
style =“font-size:10pt; font-family:”Courier New“; color:black;”> dt
style =“font-size:10pt; font-family:”Courier New“; color:navy;”>,
style =“font-size:10pt; font-family:”Courier New“; color:black;”>
one_category )
style =“font-size:10pt; font-family:”Courier New“; color:navy;”> <<
style =“font-size:10pt; font-family:”Courier New“; color:black;”>
隱藏 (
style =“font-size:10pt; font-family:”Courier New“; color:teal;”> 1
style =“font-size:10pt; font-family:”Courier New“; color:black;”>)
style =“font-size:10pt; font-family:”Courier New“; color:navy;”>;
style =“font-size:10pt; font-family:”Courier New“; color:black;”>
style =“font-size:10pt; font-family:”Courier New“; color:black;”>
style =“font-size:10pt; font-family:”Courier New“; color:green;”> //
將整個列設置為
最初為零
style =“font-size:10pt; font-family:”Courier New“; color:black;”>
style =“font-size:10pt; font-family:”Courier New“;顏色:rgb(0,0,221);”>列
style =“font-size:10pt; font-family:”Courier New“; color:black;”>(
style =“font-size:10pt; font-family:”Courier New“; color:black;”> dt
style =“font-size:10pt; font-family:”Courier New“; color:navy;”>,
style =“font-size:10pt; font-family:”Courier New“; color:black;”>
one_category )
style =“font-size:10pt; font-family:”Courier New“; color:navy;”> <<
style =“font-size:10pt; font-family:”Courier New“; color:black;”>
值 ( col_zeroes [
style =“font-size:10pt; font-family:”Courier New“; color:teal;”> 0
style =“font-size:10pt; font-family:”Courier New“; color:navy;”>,
style =“font-size:10pt; font-family:”Courier New“; color:teal;”> 1
style =“font-size:10pt; font-family:”Courier New“; color:black;”>])
style =“font-size:10pt; font-family:”Courier New“; color:navy;”>;
style =“font-size:10pt; font-family:”Courier New“; color:black;”>
style =“font-size:10pt; font-family:”Courier New“; color:black;”>
style =“font-size:10pt; font-family:”Courier New“; color:green;”> //
選擇具有值的所有行
匹配此類別
style =“font-size:10pt; font-family:”Courier New“; color:black;”>
style =“font-size:10pt; font-family:”Courier New“; color:black;”> dt
style =“font-size:10pt; font-family:”Courier New“; color:navy;”> <<
style =“font-size:10pt; font-family:”Courier New“; color:black;”>
選擇在哪裡 (
style =“font-size:10pt; font-family:”Courier New“;顏色:rgb(0,0,221);”>包含
style =“font-size:10pt; font-family:”Courier New“; color:black;”>(
style =“font-size:10pt; font-family:”Courier New“; color:black;”> category_list
style =“font-size:10pt; font-family:”Courier New“; color:navy;”>,
style =“font-size:10pt; font-family:”Courier New“; color:black;”>
style =“font-size:10pt; font-family:”Courier New“; color:navy;”>:
style =“font-size:10pt; font-family:”Courier New“; color:black;”>我的
值 ))
style =“font-size:10pt; font-family:”Courier New“; color:navy;”>;
style =“font-size:10pt; font-family:”Courier New“; color:black;”>
style =“font-size:10pt; font-family:”Courier New“; color:black;”>
style =“font-size:10pt; font-family:”Courier New“; color:green;”> //
獲取所選的列表
行
style =“font-size:10pt; font-family:”Courier New“; color:black;”>
style =“font-size:10pt; font-family:”Courier New“; color:black;”> one_cat_rows
style =“font-size:10pt; font-family:”Courier New“; color:navy;”> =
style =“font-size:10pt; font-family:”Courier New“; color:black;”>
DT
style =“font-size:10pt; font-family:”Courier New“; color:navy;”> <<
style =“font-size:10pt; font-family:”Courier New“; color:black;”>
被選中
行 ()
style =“font-size:10pt; font-family:”Courier New“; color:navy;”>;
style =“font-size:10pt; font-family:”Courier New“; color:black;”>
style =“font-size:10pt; font-family:”Courier New“; color:black;”>
style =“font-size:10pt; font-family:”Courier New“; color:green;”> //
將所有匹配的行設置為1
這個類別
style =“font-size:10pt; font-family:”Courier New“; color:black;”>
style =“font-size:10pt; font-family:”Courier New“; color:rgb(0,0,221);”> if
style =“font-size:10pt; font-family:”Courier New“; color:black;”>
(
style =“font-size:10pt; font-family:”Courier New“; color:rgb(0,0,221);”> nrows
style =“font-size:10pt; font-family:”Courier New“; color:black;”>(
style =“font-size:10pt; font-family:”Courier New“; color:black;”> one_cat_rows )
style =“font-size:10pt; font-family:”Courier New“; color:navy;”>>
style =“font-size:10pt; font-family:”Courier New“; color:black;”>
style =“font-size:10pt; font-family:”Courier New“; color:teal;”> 0
style =“font-size:10pt; font-family:”Courier New“; color:navy;”>,
style =“font-size:10pt; font-family:”Courier New“; color:black;”>
style =“font-size:10pt; font-family:”Courier New“; color:black;”>
風格=“”>
style =“font-size:10pt; font-family:”Courier New“;顏色:rgb(0,0,221);”>列
style =“font-size:10pt; font-family:”Courier New“; color:black;”>(
style =“font-size:10pt; font-family:”Courier New“; color:black;”> dt
style =“font-size:10pt; font-family:”Courier New“; color:navy;”>,
style =“font-size:10pt; font-family:”Courier New“; color:black;”>
one_category ) one_cat_rows ]
style =“font-size:10pt; font-family:”Courier New“; color:navy;”> =
style =“font-size:10pt; font-family:”Courier New“; color:black;”>
style =“font-size:10pt; font-family:”Courier New“; color:teal;”> 1
style =“font-size:10pt; font-family:”Courier New“; color:navy;”>;
style =“font-size:10pt; font-family:”Courier New“; color:black;”>
style =“font-size:10pt; line-height:115%; font-family:”Courier New“; color:black;”>)
style =“font-size:10pt; line-height:115%; font-family:”Courier New“; color:navy;”>;