问题描述
大家好,
我的master-db-server上的
我正在运行postgres 7.4.1,
我有两台运行postgres的奴隶服务器7.4.2
在主服务器上运行以下查询(7.4.1)提供:
解释分析select * from foo,其中bar喜欢''0101%''和foobar喜欢
''top%'';
索引在foo上使用foo_foobar_idx扫描(费用...)
索引条件:((foobar> =''top :: text)和(firma<''toq'':: text))
过滤:((bar ~~''0101%'':: text)和(firma ~~''top%'':: text))
总运行时间:1.519 ms
两个从站上的相同查询(7.4.2)(从主镜像,相同的
表结构等)产生:
Seq扫描foo(成本....)
过滤:((吧~~''0101%'':: text)AND(foobar~ 〜''top%'':: text))
总运行时间:722.331 ms
是否有这样的广告在7.4.1到7.4.2中的推理?
我不能接受722毫秒的延迟,我不明白为什么
没有使用索引。
你有什么想法吗?我已多次运行VACUUM ANALYZE,并且
REINDEX TABLE foo甚至
DROPped并重新编译索引。没有帮助。
BTW如果我跑:
解释分析select * from foo where bar like''0101%''和
foobar> =''top'':: text和foobar<''toq'':: text;
索引被利用,因为它应该是
任何暗示赞赏,
谢谢
-
Mit freundlichem Gru ?
Henrik Steffen
Gesch?ftsführer
顶级概念Internetmarketing GmbH
Am Steinkamp 7 - D-21684 Stade - 德国
-------------------------------- ------------------------
电话。 +49 1805 9977 501 *
邮件:传真。 +49 1805 9977 502 *
------------------------------------ --------------------
SMS Versand ab 9.9分:
--------------- -----------------------------------------
Handelsregister :AG Stade HRB 5811 - UstId:DE 213645563
-------------------------------- ------------------------
*)EUR 0,12 / Min。 (CNS24)
---------------------------(播出结束)--- ------------------------
提示5:您查看了我们广泛的常见问题解答吗?
hello all,
on my master-db-server i''m running postgres 7.4.1,
and I have got two slave-servers running postgres 7.4.2
running the following query on the master-server (7.4.1) delivers:
explain analyze select * from foo where bar like ''0101%'' and foobar like
''top%'';
Index Scan using foo_foobar_idx on foo (cost...)
Index Cond: ((foobar>=''top::text) and (firma < ''toq''::text))
Filter: ((bar ~~ ''0101%''::text) and (firma ~~ ''top%''::text))
Total runtime: 1.519 ms
the same query on both slaves (7.4.2)(mirrored from master, same
structure of table etc.) yields:
Seq Scan on foo (cost ....)
Filter: ((bar ~~ ''0101%''::text) AND (foobar ~~ ''top%''::text))
Total runtime: 722.331 ms
Is there such a difference in 7.4.1 to 7.4.2 ?
A retardation of 722 ms is not acceptable for me, and I don''t see why
the indexes are not used.
Do you have an idea? I have run VACUUM ANALYZE several times, and
REINDEX TABLE foo and even
DROPped and reCREATEd the index. Didn''t help.
BTW if I run:
explain analyze select * from foo where bar like ''0101%'' and
foobar>=''top''::text and foobar<''toq''::text;
the index is utilized as it is supposed to
Any hint appreciated,
thank you
--
Mit freundlichem Gru?
Henrik Steffen
Gesch?ftsführer
top concepts Internetmarketing GmbH
Am Steinkamp 7 - D-21684 Stade - Germany
--------------------------------------------------------
http://www.topconcepts.de Tel. +49 1805 9977 501*
mail: st*****@topconcepts.de Fax. +49 1805 9977 502*
--------------------------------------------------------
SMS Versand ab 9.9 Cent: http://sms-gw.topconcepts.de
--------------------------------------------------------
Handelsregister: AG Stade HRB 5811 - UstId: DE 213645563
--------------------------------------------------------
*) EUR 0,12/Min. (CNS24)
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?
http://www.postgresql.org/docs/faqs/FAQ.html
推荐答案
----- BEGIN PGP SIGNATURE -----
版本:GnuPG v1.0.6(GNU / Linux)
评论:有关信息请参阅
iD8DBQFAx26jY5Twig3Ge + YRAkiEAJ94CjEWm7jaNLhUWqMTPZ xh5 + f8YQCgmkau
Y8Q68BHCViU0tzj3vVjrW7U =
= 9d0w
----- END PGP SIGNATURE -----
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iD8DBQFAx26jY5Twig3Ge+YRAkiEAJ94CjEWm7jaNLhUWqMTPZ xh5+f8YQCgmkau
Y8Q68BHCViU0tzj3vVjrW7U=
=9d0w
-----END PGP SIGNATURE-----
----- BEGIN PGP SIGNATURE -----
版本:GnuPG v1.0.6(GNU / Linux)
评论:有关信息请参阅
iD8DBQFAx26jY5Twig3Ge + YRAkiEAJ94CjEWm7jaNLhUWqMTPZ xh5 + f8YQCgmkau
Y8Q68BHCViU0tzj3vVjrW7U =
= 9d0w
----- END PGP SIGNATURE -----
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iD8DBQFAx26jY5Twig3Ge+YRAkiEAJ94CjEWm7jaNLhUWqMTPZ xh5+f8YQCgmkau
Y8Q68BHCViU0tzj3vVjrW7U=
=9d0w
-----END PGP SIGNATURE-----
除非你使用text_pattern_ops。参见
我认为这需要在常见问题解答中。
---------------------------(播出结束)-------------- -------------
提示9:如果您的
加入专栏,计划员将无视您选择索引扫描的愿望数据类型不匹配
Unless you use text_pattern_ops. See
http://www.postgresql.org/docs/7.4/s...s-opclass.html
I think this needs to be in the faq.
---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column''s datatypes do not match
这篇关于使用LIKE索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!