小编Yeg*_*dov的帖子

使用串联和LIKE查询性能

有人可以解释这三个查询之间的性能差异吗?

concat() 功能:

explain analyze 
select * from person 
where (concat(last_name, ' ', first_name, ' ', middle_name) like '%???%');

Seq Scan on person  (cost=0.00..4.86 rows=1 width=15293) (actual time=0.032..0.140 rows=6 loops=1)
  Filter: (pg_catalog.concat(last_name, ' ', first_name, ' ', middle_name) ~~ '%???%'::text)
Total runtime: 0.178 ms
Run Code Online (Sandbox Code Playgroud)

SQL标准串联||

explain analyze 
select * from person 
where ((last_name || ' ' || first_name || ' ' || middle_name) like '%???%');

Seq Scan on person  (cost=0.00..5.28 rows=1 width=15293) (actual time=0.023..0.080 rows=6 loops=1)
  Filter: ((((((last_name)::text …
Run Code Online (Sandbox Code Playgroud)

sql postgresql concatenation pattern-matching postgresql-performance

3
推荐指数
2
解决办法
5062
查看次数