[英]Some issues with Sphinx and PHP
情況如下:
我的數據庫中有一個大表--3.6 GB和1,7M行。 從表中選擇限制和偏移量非常慢並且經常導致錯誤504.表是MyISAM,具有多個索引並將被更新。
這就是為什么我決定使用Sphinx列出表的內容 - 在某些情況下沒有查詢(所有行),在某些情況下使用查詢 - 它就像一個魅力。 速度驚人。
但這是問題 - 沒有查詢只返回前1000個結果。 即使我用$this->SetLimits(41, 24);
調用它$this->SetLimits(41, 24);
這應該返回id為984
到1008
的結果,但我得到的最后一個結果是id 1,000。 我嘗試更改/etc/sphinxsearch/sphinx.conf
的值,重新啟動服務,但沒有成功。 還有,這是一個好主意嗎? 我的意思是,它會明顯減慢性能嗎? 有關如何做到這一點的任何建議?
這是另一個問題:
在我的sphinx.conf
我選擇了我想用於搜索/訂單的列,它們都顯示在[matches]
部分中。 由於我不使用它們,它們只占用內存並且(我猜)在某種程度上降低了性能。 我只在我的應用程序中使用id
。 是否可以按這些列進行搜索/排序,但是從[matches]
排除它們?
我的sphinx.conf
source test {
type = mysql
sql_host = localhost
sql_user = root
sql_pass = password
sql_db = database
sql_port = 3306
sql_query = \
SELECT id, name, UNIX_TIMESTAMP(date) as date, views, rating \
FROM table \
WHERE active = 1
sql_field_string = name
sql_attr_timestamp = date
sql_attr_uint = views
sql_attr_uint = rating
sql_query_info = SELECT * FROM table WHERE id=$id
}
index test {
source = test
path = /var/lib/sphinxsearch/data/test
docinfo = extern
charset_type = utf-8
}
searchd {
listen = 9312
log = /var/log/sphinxsearch/searchd.log
query_log = /var/log/sphinxsearch/query.log
read_timeout = 5
max_children = 30
pid_file = /var/run/sphinxsearch/searchd.pid
max_matches = 10000 # I tried changing this to 10,000 - no result
seamless_rotate = 1
preopen_indexes = 1
unlink_old = 1
binlog_path = /var/lib/sphinxsearch/data
}
這是因為每個查詢的最大匹配設置也是如此,默認為1000。
在sphinx.conf中你可以設置類似的東西
max_matches = 10000
或者,在查詢中添加max_matches
$this->SetLimits(41, 24, 10000);
請注意,有兩個地方強制執行max_matches限制。 每個查詢限制由此API調用控制,但每個服務器限制也由配置文件中的max_matches設置控制。 為防止濫用RAM,服務器不允許將每個查詢限制設置為高於每服務器限制。
對於第二部分,請查看->SetSelect()
函數。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.