相关疑难解决方法(0)

PostgreSQL 中 LIKE、SIMILAR TO 或正则表达式的模式匹配

我必须编写一个简单的查询,在其中查找以 B 或 D 开头的人名:

SELECT s.name 
FROM spelers s 
WHERE s.name LIKE 'B%' OR s.name LIKE 'D%'
ORDER BY 1
Run Code Online (Sandbox Code Playgroud)

我想知道是否有办法重写它以提高性能。所以我可以避免or和/或like

postgresql index regular-expression pattern-matching string-searching

123
推荐指数
3
解决办法
18万
查看次数

带有位图索引扫描的查询计划中的“重新检查条件:”行

这是对上一个问题的评论的衍生:

使用 PostgreSQL 9.4,Recheck Cond:EXPLAIN.

就像在EXPLAIN引用问题的输出中一样:

->  Bitmap Heap Scan on table_three  (cost=2446.92..19686.74 rows=8159 width=7)
      Recheck Cond: (("timestamp" > (now() - '30 days'::interval)) AND (client_id > 0))
      ->  BitmapAnd  (cost=2446.92..2446.92 rows=8159 width=0)
            ->  Bitmap Index Scan on table_one_timestamp_idx  (cost=0.00..1040.00 rows=79941 width=0)
                  Index Cond: ("timestamp" > (now() - '30 days'::interval))
            ->  Bitmap Index Scan on fki_table_three_client_id  (cost=0.00..1406.05 rows=107978 width=0)
                  Index Cond: (client_id > 0)
Run Code Online (Sandbox Code Playgroud)

或者在EXPLAIN ANALYZE一个简单的大表(很少work_mem)的输出中:

EXPLAIN ANALYZE …
Run Code Online (Sandbox Code Playgroud)

postgresql index execution-plan postgresql-9.4

26
推荐指数
2
解决办法
1万
查看次数