多PARAMS實現搜索:
- 域
- GEO
- 引薦
- 其他PARAMS
數據庫表看起來像這樣:如何通過多個PARAMS從請求中接收
domain | geo | referer | utm | option_id |
---------|--------|---------|-----|-----------|
test.com | | | | 1
test.com | us | | | 2
test.com | us | ref.com | 12 | 3
test2.com| us | | | 4
例如我收到一些PARAMS請求:
domain=test.com
geo=us
referer=ref.com
utm=12
如果我做一個查詢:
select option_id from table where domain='test.com' and geo='us' and referer='ref.com' and utm='12';
它給了我充分的比賽結果只有option_id = 3
但我需要得到所有的選項,每場比賽有域名和地理。
option_id = [1,2,3]
如何以高性能的方式解決問題,也許解決方案不是SQL數據庫。我需要實時搜索高負載系統。 幫助將很有用,謝謝。
滿足的選擇將是該查詢:
select option_id from table where domain='test.com' and geo='' and referer='' and utm=''
UNION
select option_id from table where domain='test.com' and geo='us' and referer='' and utm=''
UNION
select option_id from table where domain='test.com' and geo='us' and referer='ref.com' and utm='12'
但它是緩慢的,我知道,存在簡單的和高性能的解決方案。也許沒有SQL數據庫
我用更多的數據展開我的示例。如果我將使用'或',它會給我選項4的結果爲另一個域名 – user1991123
也許我不完全理解你的目標。 你希望所有符合域和地緣的線條,但你說你也想與option_id = 1行,不具有地理 –
認爲空值等於任何 – user1991123