当前位置: 首页 > news >正文

openGauss关联列数据类型不一致引起谓词传递失败

今天分享一个比较有意思的案例
注意:因为原始SQL很长,为了方便排版,简化了SQL
下面SQL跑60秒才出结果,客户请求优化

select dtcs.owner, dtcs.table_name, dtcs.column_name, dct.commentsfrom dba_tab_columns dtcsleft outer join dba_col_comments dcton dct.owner = dtcs.ownerand dct.table_name = dtcs.table_nameand dct.column_name = dtcs.column_namewhere 1 = 1and dtcs.table_name = 'psph_t'and coalesce(dct.comments, 'x') <> dtcs.column_nameand exists (select *from gzda_t dawhere da.gzda001 = dtcs.ownerand da.gzda005 = 'Y');

拿到SQL不要一来就去看执行计划,应该先分析SQL写法,然后再查看数据量
dba_tab_columns,dba_col_comments是客户模仿Oracle的数据字典自己编写的2个视图,gzda_t是一个表

我们来看一下where条件过滤之后的数据量以及SQL执行时间

topprd=# select count(*) from dba_tab_columns where table_name = 'psph_t';count
-------265
(1 row)Time: 67.131 ms
topprd=# select count(*) from dba_col_comments where table_name = 'psph_t';count
-------300
(1 row)Time: 126.181 ms
topprd=# select count(*) from gzda_t where gzda005 = 'Y';count
-------4
(1 row)Time: 5.896 ms

最多才300行,执行速度也都在毫秒级,那原始SQL应该秒杀才对,不应该跑60秒
有些读者可能会有疑问,dba_col_comments没有过滤条件啊,你怎么加个where table_name = 'psph_t'
这是因为dba_tab_columns过滤条件有where table_name = 'psph_t',并且两个表关联条件是dct.table_name = dtcs.table_name
openGauss支持可传递谓词功能,这个功能在Oracle里面受到隐含参数_optimizer_filter_pushdown控制
也就是说dtcs.table_name = 'psph_t'的过滤条件会根据dct.table_name = dtcs.table_name传递给dct
经过上面的分析,得到结论,SQL应该秒杀,但是跑了60秒,现在来看一下执行计划吧

Nested Loop Left Join  (cost=659287.88..6447409.06 rows=4 width=201) (actual time=1522.588..63483.879 rows=106 loops=1)Filter: (COALESCE(d.description, 'x'::text) <> (att.attname)::text)Rows Removed by Filter: 106->  Hash Right Join  (cost=659287.88..6447367.76 rows=4 width=198) (actual time=401.930..63482.739 rows=212 loops=1)Hash Cond: (((n.nspname)::text = (nsp.nspname)::text) AND ((c.relname)::text = (cls.relname)::text) AND ((a.attname)::text = (att.attname)::text))->  Hash Join  (cost=576610.79..6337810.41 rows=1433613 width=198) (actual time=125.543..62834.698 rows=846168 loops=1)Hash Cond: (c.relnamespace = n.oid)->  Hash Join  (cost=574039.01..6332278.71 rows=1075210 width=138) (actual time=119.805..62582.638 rows=1003296 loops=1)Hash Cond: (a.attrelid = c.oid)->  Seq Scan on pg_attribute a  (cost=0.00..5755417.10 rows=1075210 width=70) (actual time=0.006..62057.869 rows=1003296 loops=1)->  Hash  (cost=573183.21..573183.21 rows=68464 width=72) (actual time=119.007..119.007 rows=60919 loops=1)Buckets: 131072  Batches: 1  Memory Usage: 7212kB->  Index Scan using pg_class_oid_index on pg_class c  (cost=0.00..573183.21 rows=68464 width=72) (actual time=0.022..95.303 rows=60919 loops=1)->  Hash  (cost=2570.32..2570.32 rows=116 width=68) (actual time=5.540..5.540 rows=117 loops=1)Buckets: 32768  Batches: 1  Memory Usage: 268kB->  Seq Scan on pg_namespace n  (cost=0.00..2570.32 rows=116 width=68) (actual time=0.017..5.504 rows=117 loops=1)Filter: (nspname !~~ 'pg_toast%'::text)Rows Removed by Filter: 67->  Hash  (cost=82677.03..82677.03 rows=4 width=192) (actual time=49.883..49.883 rows=212 loops=1)Buckets: 32768  Batches: 1  Memory Usage: 303kB->  Hash Semi Join  (cost=74287.54..82677.03 rows=4 width=192) (actual time=17.161..49.547 rows=212 loops=1)Hash Cond: (nsp.nspname = (da.gzda001)::name)->  WindowAgg  (cost=74286.33..82644.58 rows=2495 width=1791) (actual time=16.924..48.794 rows=265 loops=1)->  Sort  (cost=74286.33..74292.57 rows=2495 width=1791) (actual time=15.406..15.491 rows=265 loops=1)Sort Key: nsp.nspname, att.attnumSort Method: quicksort  Memory: 326kB->  Hash Left Join  (cost=17668.34..74145.55 rows=2495 width=1791) (actual time=11.925..14.773 rows=265 loops=1)Hash Cond: ((cls.relname = c.relname) AND (nsp.nspname = n.nspname) AND (att.attname = a.attname))->  Nested Loop Left Join  (cost=12282.79..68732.57 rows=2401 width=1775) (actual time=10.844..13.527 rows=265 loops=1)->  Hash Join  (cost=12282.79..48893.73 rows=2401 width=863) (actual time=10.814..12.536 rows=265 loops=1)Hash Cond: (cls.relnamespace = nsp.oid)->  Hash Join  (cost=9711.02..46316.99 rows=1801 width=803) (actual time=5.290..6.849 rows=265 loops=1)Hash Cond: (typ.typnamespace = tnsp.oid)->  Nested Loop  (cost=7138.83..43618.69 rows=47135 width=743) (actual time=0.188..1.659 rows=265 loops=1)->  Nested Loop  (cost=7138.83..14333.30 rows=1801 width=416) (actual time=0.158..0.468 rows=265 loops=1)->  Index Scan using pg_class_relname_nsp_index on pg_class cls  (cost=0.00..36.30 rows=1 width=80) (actual time=0.045..0.060 rows=5 loops=1)Index Cond: (relname = 'psph_t'::name)Filter: (relkind = ANY ('{r,v,t,f}'::"char"[]))->  Bitmap Heap Scan on pg_attribute att  (cost=7138.83..14274.18 rows=2283 width=340) (actual time=0.203..0.325 rows=265 loops=5)Recheck Cond: ((attrelid = cls.oid) AND (attnum >= 1))Heap Blocks: exact=12->  Bitmap Index Scan on pg_attribute_relid_attnum_index  (cost=0.00..7138.26 rows=1801 width=0) (actual time=0.154..0.154 rows=265 loops=5)Index Cond: ((attrelid = cls.oid) AND (attnum >= 1))->  Index Scan using pg_type_oid_index on pg_type typ  (cost=0.00..16.25 rows=1 width=335) (actual time=1.016..1.016 rows=265 loops=265)Index Cond: (oid = att.atttypid)->  Hash  (cost=2569.86..2569.86 rows=186 width=68) (actual time=4.890..4.890 rows=184 loops=1)Buckets: 32768  Batches: 1  Memory Usage: 274kB->  Seq Scan on pg_namespace tnsp  (cost=0.00..2569.86 rows=186 width=68) (actual time=0.007..4.830 rows=184 loops=1)->  Hash  (cost=2570.32..2570.32 rows=116 width=68) (actual time=5.306..5.306 rows=117 loops=1)Buckets: 32768  Batches: 1  Memory Usage: 268kB->  Seq Scan on pg_namespace nsp  (cost=0.00..2570.32 rows=116 width=68) (actual time=0.015..5.272 rows=117 loops=1)Filter: (nspname !~~ 'pg_toast%'::text)Rows Removed by Filter: 67->  Index Scan using pg_attrdef_adrelid_adnum_index on pg_attrdef ad  (cost=0.00..8.26 rows=1 width=918) (actual time=0.783..0.783 rows=44 loops=265)Index Cond: ((att.attrelid = adrelid) AND (att.attnum = adnum))->  Hash  (cost=5381.16..5381.16 rows=251 width=208) (actual time=0.879..0.879 rows=53 loops=1)Buckets: 32768  Batches: 1  Memory Usage: 269kB->  Nested Loop  (cost=4.26..5381.16 rows=251 width=208) (actual time=0.214..0.841 rows=53 loops=1)Join Filter: (has_column_privilege(c.oid, a.attnum, 'select'::text) AND (c.oid = a.attrelid))->  Nested Loop  (cost=0.00..515.92 rows=66 width=154) (actual time=0.111..0.272 rows=53 loops=1)->  Nested Loop  (cost=0.00..109.09 rows=2 width=132) (actual time=0.049..0.096 rows=5 loops=1)->  Index Scan using pg_class_relname_nsp_index on pg_class c  (cost=0.00..36.29 rows=2 width=72) (actual time=0.026..0.045 rows=5 loops=1)Index Cond: (relname = 'psph_t'::name)->  Index Scan using pg_namespace_oid_index on pg_namespace n  (cost=0.00..24.27 rows=1 width=68) (actual time=0.040..0.040 rows=5 loops=5)Index Cond: (oid = c.relnamespace)->  Index Scan using pg_statistic_relid_kind_att_inh_index on pg_statistic s  (cost=0.00..136.99 rows=6642 width=22) (actual time=0.061..0.160 rows=53 loops=5)Index Cond: ((starelid = c.oid) AND (starelkind = 'c'::"char"))->  Bitmap Heap Scan on pg_attribute a  (cost=4.26..72.43 rows=17 width=70) (actual time=0.288..0.288 rows=53 loops=53)Recheck Cond: ((attrelid = s.starelid) AND (attnum = s.staattnum))Filter: (NOT attisdropped)Heap Blocks: exact=53->  Bitmap Index Scan on pg_attribute_relid_attnum_index  (cost=0.00..4.26 rows=17 width=0) (actual time=0.200..0.200 rows=53 loops=53)Index Cond: ((attrelid = s.starelid) AND (attnum = s.staattnum))->  Hash  (cost=1.16..1.16 rows=4 width=6) (actual time=0.032..0.032 rows=4 loops=1)Buckets: 32768  Batches: 1  Memory Usage: 257kB->  Seq Scan on gzda_t da  (cost=0.00..1.16 rows=4 width=6) (actual time=0.011..0.016 rows=4 loops=1)Filter: ((gzda005)::text = 'Y'::text)Rows Removed by Filter: 9->  Index Scan using pg_description_o_c_o_index on pg_description d  (cost=0.00..8.25 rows=1 width=17) (actual time=0.812..0.812 rows=106 loops=212)Index Cond: ((a.attrelid = objoid) AND (classoid = 1259::oid) AND (a.attnum = objsubid))
Total runtime: 63488.041 ms

执行计划中

  ->  Hash Right Join  (cost=659287.88..6447367.76 rows=4 width=198) (actual time=401.930..63482.739 rows=212 loops=1)Hash Cond: (((n.nspname)::text = (nsp.nspname)::text) AND ((c.relname)::text = (cls.relname)::text) AND ((a.attname)::text = (att.attname)::text))

表示 dtcs left join dct on dct.owner = dtcs.owner and dct.table_name = dtcs.table_name and dct.column_name = dtcs.column_name    

执行计划中

        ->  Hash Join  (cost=576610.79..6337810.41 rows=1433613 width=198) (actual time=125.543..62834.698 rows=846168 loops=1)Hash Cond: (c.relnamespace = n.oid)->  Hash Join  (cost=574039.01..6332278.71 rows=1075210 width=138) (actual time=119.805..62582.638 rows=1003296 loops=1)Hash Cond: (a.attrelid = c.oid)->  Seq Scan on pg_attribute a  (cost=0.00..5755417.10 rows=1075210 width=70) (actual time=0.006..62057.869 rows=1003296 loops=1)->  Hash  (cost=573183.21..573183.21 rows=68464 width=72) (actual time=119.007..119.007 rows=60919 loops=1)Buckets: 131072  Batches: 1  Memory Usage: 7212kB->  Index Scan using pg_class_oid_index on pg_class c  (cost=0.00..573183.21 rows=68464 width=72) (actual time=0.022..95.303 rows=60919 loops=1)->  Hash  (cost=2570.32..2570.32 rows=116 width=68) (actual time=5.540..5.540 rows=117 loops=1)Buckets: 32768  Batches: 1  Memory Usage: 268kB->  Seq Scan on pg_namespace n  (cost=0.00..2570.32 rows=116 width=68) (actual time=0.017..5.504 rows=117 loops=1)Filter: (nspname !~~ 'pg_toast%'::text)Rows Removed by Filter: 67

是dba_col_comments dct,仔细观察执行计划,没有where table_name = 'psph_t'的过滤信息,也就是说没有发生谓词传递
先做个小实验,确认一下openGauss是否支持谓词传递

create table t1(id number,name varchar2(100));
create table t2(id number,comm varchar2(100));
insert into t1 values(1,'CHINA');
insert into t1 values(2,'JAPAN');
insert into t2 values(1,'牛逼');
commit;oracle=> explain select * from t1 left join t2 on t1.id=t2.id where t1.id=1;QUERY PLAN                            
-----------------------------------------------------------------Hash Left Join  (cost=13.66..27.33 rows=1 width=500)Hash Cond: (t1.id = t2.id)->  Seq Scan on t1  (cost=0.00..13.65 rows=1 width=250)Filter: (id = 1::numeric)->  Hash  (cost=13.65..13.65 rows=1 width=250)->  Seq Scan on t2  (cost=0.00..13.65 rows=1 width=250)Filter: (id = 1::numeric)
(7 rows)

查看上面执行计划,t2表对id列做了过滤 Filter: (id = 1::numeric),也就是说openGauss支持谓词传递
经过上面分析,我们得到结论,原始SQL没有进行谓词传递,既然数据库没有自动进行谓词传递,那么我们就人工传递

select dtcs.owner, dtcs.table_name, dtcs.column_name, dct.commentsfrom dba_tab_columns dtcsleft outer join dba_col_comments dcton dct.owner = dtcs.ownerand dct.table_name = dtcs.table_nameand dct.column_name = dtcs.column_nameand dct.table_name='psph_t'  ---人工传递谓词where 1 = 1and dtcs.table_name = 'psph_t'and coalesce(dct.comments, 'x') <> dtcs.column_nameand exists (select *from gzda_t dawhere da.gzda001 = dtcs.ownerand da.gzda005 = 'Y');

上面SQL的注释部分就是人工传递谓词的过滤条件,SQL秒杀,执行计划如下

Nested Loop Left Join  (cost=192358.27..6031726.77 rows=4 width=201) (actual time=127.956..212.777 rows=106 loops=1)Filter: (COALESCE(d.description, 'x'::text) <> (att.attname)::text)Rows Removed by Filter: 106->  Hash Right Join  (cost=192358.27..6031685.47 rows=4 width=198) (actual time=71.544..211.792 rows=212 loops=1)Hash Cond: (((n.nspname)::text = (nsp.nspname)::text) AND ((c.relname)::text = (cls.relname)::text) AND ((a.attname)::text = (att.attname)::text))->  Hash Join  (cost=11197.98..5833555.24 rows=905063 width=198) (actual time=17.358..156.901 rows=300 loops=1)Hash Cond: (c.relnamespace = n.oid)->  Nested Loop  (cost=8586.90..5829179.63 rows=669341 width=138) (actual time=11.802..151.253 rows=300 loops=1)->  Index Scan using pg_class_oid_index on pg_class c  (cost=0.00..544818.35 rows=307 width=72) (actual time=11.739..150.856 rows=5 loops=1)Filter: ((relname)::text = 'psph_t'::text)Rows Removed by Filter: 60971->  Bitmap Heap Scan on pg_attribute a  (cost=8586.90..17191.10 rows=2180 width=70) (actual time=0.188..0.262 rows=300 loops=5)Recheck Cond: (attrelid = c.oid)Heap Blocks: exact=15->  Bitmap Index Scan on pg_attribute_relid_attnum_index  (cost=0.00..8586.36 rows=2180 width=0) (actual time=0.124..0.124 rows=300 loops=5)Index Cond: (attrelid = c.oid)->  Hash  (cost=2594.32..2594.32 rows=1340 width=68) (actual time=5.354..5.354 rows=117 loops=1)Buckets: 32768  Batches: 1  Memory Usage: 268kB->  Seq Scan on pg_namespace n  (cost=0.00..2594.32 rows=1340 width=68) (actual time=0.024..5.312 rows=117 loops=1)Filter: (nspname !~~ 'pg_toast%'::text)Rows Removed by Filter: 67->  Hash  (cost=181160.22..181160.22 rows=4 width=192) (actual time=53.709..53.709 rows=212 loops=1)Buckets: 32768  Batches: 1  Memory Usage: 303kB->  Hash Semi Join  (cost=151533.19..181160.22 rows=4 width=192) (actual time=18.529..53.296 rows=212 loops=1)Hash Cond: (nsp.nspname = (da.gzda001)::name)->  WindowAgg  (cost=151531.98..181048.83 rows=8811 width=2618) (actual time=18.274..52.512 rows=265 loops=1)->  Sort  (cost=151531.98..151554.00 rows=8811 width=2618) (actual time=16.753..16.863 rows=265 loops=1)Sort Key: nsp.nspname, att.attnumSort Method: quicksort  Memory: 326kB->  Hash Left Join  (cost=18995.91..135323.63 rows=8811 width=2618) (actual time=12.843..16.111 rows=265 loops=1)Hash Cond: ((cls.relname = c.relname) AND (nsp.nspname = n.nspname) AND (att.attname = a.attname))->  Nested Loop Left Join  (cost=12082.62..128357.38 rows=4697 width=2602) (actual time=10.714..13.806 rows=265 loops=1)->  Hash Join  (cost=12082.62..89555.16 rows=4697 width=1690) (actual time=10.684..12.700 rows=265 loops=1)Hash Cond: (cls.relnamespace = nsp.oid)->  Hash Join  (cost=9471.55..86934.92 rows=3474 width=1630) (actual time=5.090..6.948 rows=265 loops=1)Hash Cond: (typ.typnamespace = tnsp.oid)->  Nested Loop  (cost=6856.16..84053.46 rows=101159 width=1570) (actual time=0.171..1.914 rows=265 loops=1)->  Nested Loop  (cost=6856.16..27579.13 rows=3474 width=416) (actual time=0.144..0.570 rows=265 loops=1)->  Index Scan using pg_class_relname_nsp_index on pg_class cls  (cost=0.00..56.32 rows=2 width=80) (actual time=0.040..0.065 rows=5 loops=1)Index Cond: (relname = 'psph_t'::name)Filter: (relkind = ANY ('{r,v,t,f}'::"char"[]))->  Bitmap Heap Scan on pg_attribute att  (cost=6856.16..13739.61 rows=2180 width=340) (actual time=0.283..0.429 rows=265 loops=5)Recheck Cond: ((attrelid = cls.oid) AND (attnum >= 1))Heap Blocks: exact=12->  Bitmap Index Scan on pg_attribute_relid_attnum_index  (cost=0.00..6855.62 rows=1737 width=0) (actual time=0.226..0.226 rows=265 loops=5)Index Cond: ((attrelid = cls.oid) AND (attnum >= 1))->  Index Scan using pg_type_oid_index on pg_type typ  (cost=0.00..16.25 rows=1 width=1162) (actual time=1.161..1.161 rows=265 loops=265)Index Cond: (oid = att.atttypid)->  Hash  (cost=2589.06..2589.06 rows=2106 width=68) (actual time=4.756..4.756 rows=184 loops=1)Buckets: 32768  Batches: 1  Memory Usage: 274kB->  Seq Scan on pg_namespace tnsp  (cost=0.00..2589.06 rows=2106 width=68) (actual time=0.014..4.687 rows=184 loops=1)->  Hash  (cost=2594.32..2594.32 rows=1340 width=68) (actual time=5.379..5.379 rows=117 loops=1)Buckets: 32768  Batches: 1  Memory Usage: 268kB->  Seq Scan on pg_namespace nsp  (cost=0.00..2594.32 rows=1340 width=68) (actual time=0.024..5.343 rows=117 loops=1)Filter: (nspname !~~ 'pg_toast%'::text)Rows Removed by Filter: 67->  Index Scan using pg_attrdef_adrelid_adnum_index on pg_attrdef ad  (cost=0.00..8.26 rows=1 width=918) (actual time=0.858..0.858 rows=44 loops=265)Index Cond: ((att.attrelid = adrelid) AND (att.attnum = adnum))->  Hash  (cost=6903.94..6903.94 rows=534 width=208) (actual time=1.965..1.965 rows=53 loops=1)Buckets: 32768  Batches: 1  Memory Usage: 269kB->  Nested Loop  (cost=4.26..6903.94 rows=534 width=208) (actual time=0.212..1.919 rows=53 loops=1)Join Filter: (has_column_privilege(c.oid, a.attnum, 'select'::text) AND (c.oid = a.attrelid))->  Nested Loop  (cost=0.00..714.96 rows=101 width=154) (actual time=0.104..1.359 rows=53 loops=1)->  Nested Loop  (cost=0.00..89.38 rows=3 width=132) (actual time=0.041..0.096 rows=5 loops=1)->  Index Scan using pg_class_relname_nsp_index on pg_class c  (cost=0.00..56.30 rows=3 width=72) (actual time=0.019..0.039 rows=5 loops=1)Index Cond: (relname = 'psph_t'::name)->  Index Scan using pg_namespace_oid_index on pg_namespace n  (cost=0.00..8.27 rows=1 width=68) (actual time=0.046..0.046 rows=5 loops=5)Index Cond: (oid = c.relnamespace)->  Index Scan using pg_statistic_relid_kind_att_inh_index on pg_statistic s  (cost=0.00..141.02 rows=6751 width=22) (actual time=0.063..1.242 rows=53 loops=5)Index Cond: ((starelid = c.oid) AND (starelkind = 'c'::"char"))->  Bitmap Heap Scan on pg_attribute a  (cost=4.26..60.41 rows=21 width=70) (actual time=0.303..0.303 rows=53 loops=53)Recheck Cond: ((attrelid = s.starelid) AND (attnum = s.staattnum))Filter: (NOT attisdropped)Heap Blocks: exact=53->  Bitmap Index Scan on pg_attribute_relid_attnum_index  (cost=0.00..4.26 rows=14 width=0) (actual time=0.206..0.206 rows=53 loops=53)Index Cond: ((attrelid = s.starelid) AND (attnum = s.staattnum))->  Hash  (cost=1.16..1.16 rows=4 width=6) (actual time=0.032..0.032 rows=4 loops=1)Buckets: 32768  Batches: 1  Memory Usage: 257kB->  Seq Scan on gzda_t da  (cost=0.00..1.16 rows=4 width=6) (actual time=0.010..0.013 rows=4 loops=1)Filter: ((gzda005)::text = 'Y'::text)Rows Removed by Filter: 9->  Index Scan using pg_description_o_c_o_index on pg_description d  (cost=0.00..8.25 rows=1 width=17) (actual time=0.728..0.728 rows=106 loops=212)Index Cond: ((a.attrelid = objoid) AND (classoid = 1259::oid) AND (a.attnum = objsubid))
Total runtime: 216.188 ms

虽然SQL从60秒优化到秒杀,但是还没完,要分析是什么原因导致谓词传递失败,是BUG还是其他什么原因
如果是BUG,要给内核研发提需求,修复BUG。

视图dba_col_comments的定义如下

SELECT dba_col_comments1.owner, dba_col_comments1.table_name, dba_col_comments1.column_name, dba_col_comments1.comments FROM 
(SELECT (n.nspname) ::text AS owner,(c.relname) ::text AS table_name,(a.attname) ::text AS column_name,d.description AS commentsFROM (((pg_attribute a JOIN pg_class c ON((a.attrelid = c.oid))) JOINpg_namespace n ON((c.relnamespace = n.oid))) LEFT JOINpg_description dON((((a.attrelid = d.objoid) AND (a.attnum = d.objsubid)) AND(d.classoid = ('pg_class' ::regclass) ::oid))))WHERE (n.nspname !~~ 'pg_toast%'::text)
) dba_col_comments1

注意观察::text,它表示强制类型转换为text,我们想要传递谓词的列是table_name,也就是pg_class.relname,现在来看一下pg_class.relname是什么数据类型

topprd=# \d pg_classTable "pg_catalog.pg_class"Column      |       Type       | Modifiers
------------------+------------------+-----------relname          | name             | not null
.....省略...

pg_class.relname数据类型是name,但是被转成了text

视图dba_tab_columns的定义非常复杂,这里就不贴了,视图dba_tab_columns的table_name没有做类型转换,table_name同样来自pg_class.relname

现在去掉::text类型转换看看SQL速度

select dtcs.owner, dtcs.table_name, dtcs.column_name, dct.commentsfrom dba_tab_columns dtcsleft outer join (SELECT dba_col_comments1.owner,dba_col_comments1.table_name,dba_col_comments1.column_name,dba_col_comments1.commentsFROM (SELECT (n.nspname) AS owner,  ---去掉了::text(c.relname) AS table_name, ---去掉了::text(a.attname) AS column_name, ---去掉了::textd.description AS commentsFROM (((pg_attribute a JOIN pg_class cON((a.attrelid = c.oid))) JOINpg_namespace nON((c.relnamespace = n.oid))) LEFT JOINpg_description dON((((a.attrelid = d.objoid) AND(a.attnum = d.objsubid)) AND(d.classoid = ('pg_class' ::regclass)::oid))))WHERE (n.nspname !~~ 'pg_toast%'::text)) dba_col_comments1) dcton dct.owner = dtcs.ownerand dct.table_name = dtcs.table_nameand dct.column_name = dtcs.column_namewhere 1 = 1and dtcs.table_name = 'psph_t'and coalesce(dct.comments, 'x') <> dtcs.column_nameand exists (select *from gzda_t dawhere da.gzda001 = dtcs.ownerand da.gzda005 = 'Y');

上面SQL秒杀,执行计划就不贴了

写在最后

在某交易所遇到过n起bpchar,text数据类型不一致导致常量无法推入视图
磐维遇到过几起ROWID与ROWID关联数据类型不明确引起性能问题
利用CTID删除重复数据CTID与CTID数据类型不明确无法走HASH JOIN遇到性能问题
今天遇到列数据类型不一致引起谓词传递功能失效导致性能问题
...........................省略.............................
在OG/PG系数据库中,列数据类型转换一定要小心小心再小心

相关文章:

openGauss关联列数据类型不一致引起谓词传递失败

今天分享一个比较有意思的案例 注意&#xff1a;因为原始SQL很长&#xff0c;为了方便排版&#xff0c;简化了SQL 下面SQL跑60秒才出结果&#xff0c;客户请求优化 select dtcs.owner, dtcs.table_name, dtcs.column_name, dct.commentsfrom dba_tab_columns dtcsleft outer j…...

【网络安全基础学习】渗透测试工具--Burp Suite详细教程

Burp Suite与SniffMaster&#xff1a;网络安全工具的双剑合璧 Burp Suite&#xff08;简称BP&#xff09;是一款用于攻击web应用程序的集成平台。它包含了许多工具&#xff0c;并为这些工具设计了许多接口&#xff0c;以促进加快攻击应用程序的过程。然而&#xff0c;除了Burp…...

手机测试,工作中学习

要学习各种机型的截图方式、开发模式在哪。 荣耀机型&#xff1a;截图&#xff1a;关节快速敲两下。开发者模式在“系统和更新”里。 1.出现缺陷&#xff0c;需要获取日志。 学习adb生成日志&#xff1a;当测试中出现缺陷的&#xff0c;使用adb logcat -d > d:/log.txt …...

ctfshow WEB web2

1.查当前数据库名称 or 11 union select 1,database(),3 limit 1,2;#-- 得到数据库名称web2 2.查看数据库表的数量 or 11 union select 1,(select count(*) from information_schema.tables where table_schema web2),3 limit 1,2;#-- 得到数据库表数量为2 3.查表的名字 第…...

大疆上云api介绍

概述 目前对于 DJI 无人机接入第三方云平台,主要是基于 MSDK 开发定制 App,然后自己定义私有上云通信协议连接到云平台中。这样对于核心业务是开发云平台,无人机只是其中一个接入硬件设备的开发者来说,重新基于 MSDK 开发 App 工作量大、成本高,同时还需要花很多精力在无人…...

ASP.NET Web API + VUE3 整合阿里云OSS,后端API生成预签名上传Url,前端VUE进行上传

1、后端API 我用的是.net sdk6&#xff0c;所以先安装了这个Aliyun.OSS.SDK.NetCore 下面是后端生成上传Url的参考代码&#xff0c;主意request.ContentType&#xff0c;如果这里要是设置了&#xff0c;那么前端也要设置成一样的&#xff0c;如果前端是获取文件的contentType&…...

Java基础 3.22

1.break练习 //1-100之内的数求和&#xff0c;求当和第一次大于20的当前数i public class Break01 {public static void main(String[] args) {int n 0;int count 0;for (int i 1; i < 100; i) {count i;System.out.println("当前和为" count);if (count &g…...

如何快速解决 Postman 报错?

介绍一些 Postman 常见的报错与处理方法&#xff0c;希望能够对大家有所帮助。 Postman 一直转圈打不开的问题 Postman 报错处理指南&#xff1a;常见报错与解决方法...

软件性能效率测试工具有哪些?专业第三方软件检测机构推荐

在软件开发的新时代&#xff0c;软件性能效率测试已经成为每个企业不可或缺的一部分。无论是在竞争激烈的市场中&#xff0c;还是在追求卓越用户体验的过程中&#xff0c;都需要进行有效的性能测试。 一、软件性能效率测试的目标   1、响应时间&#xff1a;确保用户请求的响…...

手机销售终端MPR+LTC项目项目总体方案P183(183页PPT)(文末有下载方式)

资料解读&#xff1a;手机销售终端 MPRLTC 项目项目总体方案 详细资料请看本解读文章的最后内容。在当今竞争激烈的市场环境下&#xff0c;企业的销售模式和流程对于其发展起着至关重要的作用。华为终端正处于销售模式转型的关键时期&#xff0c;波士顿 - 华为销售终端 MPRLTC …...

redis使用

redis集群搭建可参考&#xff1a;redis集群搭建-CSDN博客 一、简述 Redis&#xff08;Remote Dictionary Server&#xff09;是一个开源的、基于内存的高性能键值对存储系统&#xff0c;通常用作数据库、缓存和消息代理。它支持多种数据结构&#xff0c;包括字符串、哈希、列…...

深入 SVG:矢量图形、滤镜与动态交互开发指南

1.SVG 详细介绍 SVG&#xff08;Scalable Vector Graphics&#xff09; 是一种基于 XML 的矢量图形格式&#xff0c;用于描述二维图形。 1. 命名空间 (Namespace) ★ 了解 命名空间 URI&#xff1a;http://www.w3.org/2000/svg 用途&#xff1a;在 XML 或 XHTML 中区分不同标…...

从双指针到单调栈,深挖“接雨水”的算法奥秘

从双指针到单调栈&#xff0c;深挖“接雨水”的算法奥秘 大家好&#xff0c;我是你们熟悉的算法领域大牛Echo_Wish。今天我们聊聊经典题目《接雨水》&#xff08;Trapping Rain Water&#xff09;&#xff0c;不仅仅是讲解&#xff0c;而是深度对比两种高效解法&#xff1a;双…...

Labview和C#调用KNX API 相关东西

叙述:完全没有听说过KNX这个协议...................我这次项目中也是简单的用了一下没有过多的去研究 C#调用示例工程链接(labview调用示例在 DEBUG文件夹里面) 通过网盘分享的文件&#xff1a;KNX调用示例.zip 链接: https://pan.baidu.com/s/1NQUEYM11HID0M4ksetrTyg?pwd…...

Wireshark网络抓包分析使用详解

序言 之前学计网还有前几天备考华为 ICT 网络赛道时都有了解认识 Wireshark&#xff0c;但一直没怎么专门去用过&#xff0c;也没去系统学习过&#xff0c;就想趁着备考的网络相关知识还没忘光&#xff0c;先来系统学下整理点笔记~ 什么是抓包&#xff1f;抓包就是将网络传输…...

linux命令行工具进阶

文章目录 前言ssh免密登录&#xff0c;免密码登录&#xff0c;公私钥查看与修改IP地址临时修改永久修改 mount临时切换根文件系统永久切换根文件系统loop文件partedinitramfsuboot command line 前言 本文记录了一些不经常用到&#xff0c;但在某个时刻需要用到的一些指令。 免…...

【Linux文件IO】Linux中标准IO的API的描述和基本用法

Linux中标准IO的API的描述和基本用法 一、标准IO相关API1、文件的打开和关闭示例代码&#xff1a; 2、文件的读写示例代码&#xff1a;用标准IO&#xff08;fread、fwrite&#xff09;实现文件拷贝(任何文件均可拷贝) 3、文件偏移设置示例代码&#xff1a; 4、fgets fputs fget…...

【netstat和ss】Windows和Linux下的,网络连接排查简单案例

网络连接排查利器&#xff1a;netstat与ss命令详解 初识netstat&#xff1a;Windows下的网络连接查看工具 需要查看本机的网络连接情况时&#xff0c;Windows系统提供了一个非常实用的命令&#xff1a;netstat。和findstr组合形成一个有用的组合命令&#xff1a; netstat -a…...

【WPF】MVVM模式实现数据绑定以及Command事件绑定

1.引用类 using System.ComponentModel2.创建Command自定义类 public class DelegateCommand : ICommand{public bool CanExecute(object parameter){if (CanExecuteFunc null)return true;return this.CanExecuteFunc(parameter);}public event EventHandler CanExecuteChan…...

Flutter快速搭建聊天

之前项目中使用的环信聊天&#xff0c;我们的App使用的Flutter开发的 。 所以&#xff0c;就使用的 em_chat_uikit &#xff0c;这个是环信开发的Flutter版本的聊天。 一开始&#xff0c;我们也用的环信的聊天&#xff0c;是收费的&#xff0c;但是&#xff0c;后面就发现&…...

网络层之IP协议

在讨论传输层时, 我们都只讨论了发送方和接收方的问题, 而没有讨论中间的网络形态的问题. 也就是数据包如何从主机传送到主机的? 如图, 主机B发送数据到主机C, 发送报文需要进行路径选择, 主机B-> F-> G-> H-> C-> D -> 主机C 这条路径是如何被选择出来的?…...

【设计模式】策略模式(Strategy Pattern)详解

策略模式&#xff08;Strategy Pattern&#xff09;详解 一、策略模式的定义 策略模式&#xff08;Strategy Pattern&#xff09;是一种行为型设计模式&#xff0c;它定义了一组算法&#xff0c;将每个算法封装起来&#xff0c;并使它们可以相互替换&#xff0c;从而让算法的…...

Elasticsearch:构建 AI 驱动的搜索体验

Elasticsearch 介绍 当你开始使用 Elastic 时&#xff0c;你将使用 Elasticsearch Relevance Engine™&#xff08;ESRE&#xff09;&#xff0c;它专为 AI 搜索应用程序提供支持。借助 ESRE&#xff0c;你可以利用一整套开发者工具&#xff0c;包括 Elastic 的文本搜索、向量…...

数据文件误删除,OceanBase中如何重建受影响的节点

当不慎误删数据文件且当前没有现成的可替换节点时&#xff0c;在OceanBase中&#xff0c;不必急于采取极端措施&#xff0c;可以考虑运用 server_permanent_offline_time 参数&#xff0c;来重建受影响的节点。 原理&#xff1a; server_permanent_offline_time 是 OceanBase数…...

MySQL面试专题

1.什么是BufferPool&#xff1f; Buffer Pool基本概念 Buffer Pool&#xff1a;缓冲池&#xff0c;简称BP。其作用是用来缓存表数据与索引数据&#xff0c;减少磁盘IO操作&#xff0c;提升效率。 Buffer Pool由缓存数据页(Page) 和 对缓存数据页进行描述的控制块 组成, 控制…...

Redmi Note 11 T pro + 刷入 LinegaOs 22.1 记录 手机已经解锁bl.

Redmi Note 11 T pro 刷入 LinegaOs 22.1 记录 手机已经解锁bl. 获取LIneagaOS源码&#xff0c; 以及https://github.com/xiaomi-mediatek-devs 这个组织提供的代码&#xff0c;非常感谢 环境要求&#xff1a; ubuntu 22.04 需要准备的依赖 sudo apt install git curl vim…...

Python+Requests+Pytest+YAML+Allure接口自动化框架

GitHub源码地址&#xff08;详细注释&#xff09;&#xff1a;源码 调试项目python自主搭建&#xff1a;附项目源码 一、项目介绍 本项目是基于 PythonRequestsPytestYAMLAllure 搭建的 接口自动化测试框架&#xff0c;用于对 REST API 进行测试。 框架的主要特点包括&#…...

如何解决Redis缓存异常问题(雪崩、击穿、穿透)

引言 Redis作为一种高性能的内存数据库&#xff0c;被广泛应用于缓存系统的构建中。然而&#xff0c;在实际应用过程中&#xff0c;我们常常会遇到三种典型的缓存异常问题&#xff1a;缓存雪崩、缓存击穿和缓存穿透。这些问题如果处理不当&#xff0c;可能会导致系统性能下降&…...

如何使用 Postman 进行接口测试?

使用 Postman 这一工具&#xff0c;可以轻松地进行接口测试。以下是一份简单的使用教程&#xff0c;帮助你快速上手。 Postman 接口测试教程&#xff1a;详细步骤及操作技巧...

记一次线上环境JAR冲突导致程序报错org.springframework.web.util.NestedServletException

一、问题描述 有个文件导入功能&#xff0c;用到了Hutool 的加密解密功能&#xff0c;本地运行完全可以&#xff0c;但是线上报错&#xff1a;“org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is java.lang.NoClassDefFou…...

VLAN实验

一&#xff1a;实验拓扑 二&#xff1a;实验需求 1、PC1和PC3所在接口为access接口&#xff0c;属于VLAN 2 2、PC2/4/5/6处于同一网段 其中PC2可以访问PC4/5/6 PC4可以访问PC5不能访问PC6 PC5不能访问PC6 3、PC1/3和PC2/4/5/6不在一个网段&#xff0c;且可以正常通讯 4、…...

FPGA中串行执行方式之状态机

FPGA中串行执行方式之状态机 在FPGA中,默认情况下,逻辑是并行执行的,因为FPGA的硬件资源是并行的。然而,在某些情况下,你可能需要某一段逻辑以串行方式执行。这可以通过以下几种方法实现:使用状态机(Finite State Machine, FSM)​、使用计数器控制、使用流水线(Pipel…...

【常用的中间件】

中间件&#xff08;Middleware&#xff09;是位于客户端和服务器之间的软件层&#xff0c;用于处理客户端请求和服务器响应之间的各种任务。中间件可以提供多种功能&#xff0c;如负载均衡、消息队列、缓存、身份验证等。以下是常用的中间件及其作用&#xff1a; 1. 消息队列中…...

spring - 十二种事务失效场景

目录 ​编辑 一、方法内部调用 1、原理: 2、结论: 3、解决方法: 1. 增加一个service,把一个事务的方法移到新增加的service方法里面,然后进行注入再调用 2. 在自己类中注入自己 3. 通过AopContentent 二、访问权限不是pubilc 三、方法用final修饰 四、没有被spr…...

python脚本处理excel文件

1.对比perl和python 分别尝试用perl和python处理excel文件&#xff0c;发现perl的比较复杂&#xff0c;比如说read excel就有很多方式 Spreadsheet::Read use Spreadsheet::ParseExcel 不同的method&#xff0c;对应的取sheet的cell方式也不一样。更复杂的是处理含有中文内…...

C#基础学习(二)C#数组生存手册:从入门到“血压拉满“的奇妙旅程

作为一只C#萌新&#xff0c;当你试图用数组装下整个世界时&#xff0c;系统可能会温柔地弹出一句**"Index was outside the bounds of the array."**。别慌&#xff01;这份求生指南将用段子教你玩转数组 一、数组是什么 数组简单来说就是由相同元素组成的一个集合&a…...

MySQL 性能优化方向

MySQL 性能优化是一个系统性的工作,涉及数据库设计、查询优化、索引优化、硬件配置等多个方面。以下是 MySQL 性能优化的主要方向和具体优化方案: 一、数据库设计优化 1. 合理设计表结构 规范化设计:避免数据冗余,确保数据一致性。适度反规范化:在查询频繁的场景下,适当…...

2025年- G26-Lc100-57.插入间隔(max、min)--java版

1.题目描述 题目翻译&#xff1a; 给定一个不重叠的区间阵列 intervals&#xff0c;其中intervals[i] [starti, endi]表示第i一个区间的起始位置和结束位置&#xff0c;并且intervals 按照起始位置starti升序排序。 另外&#xff0c;给定一个新的区间newInterval [start, e…...

Burp Suite HTTPS解密原理

HTTPS HTTPS是在HTTP的基础上增加了SSL/TLS协议&#xff0c;提供了数据的加密、完整性校验和身份认证等安全保障。HTTPS的工作过程可以分为两个阶段&#xff1a;握手阶段和数据传输阶段。 流程如下图所示&#xff1a; 通过上面的图可以看到&#xff0c;在TCP建立连接后会发起…...

【ESP32S3】esp32获取串口数据并通过http上传到前端

通过前面的学习&#xff08;前面没发过&#xff0c;因为其实就是跑它的demo&#xff09;了解到串口配置以及开启线程实现功能的工作流程&#xff0c;与此同时还有esp32作为STA节点&#xff0c;将数据通过http发送到服务器。 将这两者联合 其实是可以得到一个&#xff1a;esp32获…...

怎么查看linux是Ubuntu还是centos

要确定你的Linux系统是基于Ubuntu还是CentOS&#xff0c;可以通过几种不同的方法来进行判断。下面是一些常用的方法&#xff1a; 要快速判断 Linux 系统是 Ubuntu 还是 CentOS&#xff0c;可通过以下方法综合验证&#xff1a; 一、查看系统信息文件 1. /etc/os-release 文件…...

Qt进程间通信:QSharedMemory 使用详解

1. 什么是 QSharedMemory&#xff1f; QSharedMemory 是 Qt 中用于进程间共享内存的类。它允许多个进程共享一块内存区域&#xff0c;从而避免数据传输时的 IO 操作&#xff0c;提高通信速度。通过共享内存&#xff0c;多个进程可以直接读写这块内存&#xff0c;而无需经过文件…...

【day1】数据结构刷题 链表

一 反转链表 206. 反转链表 给你单链表的头节点 head &#xff0c;请你反转链表&#xff0c;并返回反转后的链表。 示例 1&#xff1a; 输入&#xff1a;head [1,2,3,4,5] 输出&#xff1a;[5,4,3,2,1]示例 2&#xff1a; 输入&#xff1a;head [1,2] 输出&#xff1a;[2,1]…...

使用redis设置店铺状态

知识点&#xff1a; 将前端传过来的status&#xff08;0&#xff0c;1&#xff09;通过redis对象以key&#xff0c;values值的形式存放在redis中。 #设置店铺状态 redisTemplate.opsForValue().set(KEY,status); #获取店铺状态 Integer status (Integer) redisTemplate.o…...

基于python+django的商城网站-电子商城管理系统源码+运行

基于 python 开发的电子商城网站&#xff0c;平台采用 B/S 结构&#xff0c;后端采用主流的 Python 语言进行开发&#xff0c;前端采用主流的 Vue.js 进行开发。该系统是给师弟做的课程作业。同学们可以拿去自用。学习问题可以留言哦。 整个平台包括前台和后台两个部分。 前台…...

深度解读 C 语言运算符:编程运算的核心工具

一、引言 在 C 语言的编程世界中&#xff0c;运算符是构建逻辑与运算的基石&#xff0c;它如同一位指挥家&#xff0c;精准地协调着程序中各种数据的操作与处理。C 语言丰富多样的运算符涵盖了算术、关系、逻辑、位运算、赋值以及其他杂项运算等多个领域&#xff0c;为开发者提…...

docker中间件部署

1.docker安装 # 1.卸载旧版本 yum remove docker \docker-client \docker-client-latest \docker-common \docker-latest \docker-latest-logrotate \docker-logrotate \docker-engine# 2.需要的安装包 yum install -y yum-utils# 3.设置镜像的仓库 # 3.1.默认是国外的&#x…...

【Python Cookbook】字符串和文本(二)

字符串和文本&#xff08;二&#xff09; 6.字符串忽略大小写的搜索替换7.最短匹配模式8.多行匹配模式9.将 Unicode 文本标准化10.在正则式中使用 Unicode 6.字符串忽略大小写的搜索替换 你需要以忽略大小写的方式搜索与替换文本字符串。 为了在文本操作时忽略大小写&#xf…...

docker pull时报错:https://registry-1.docker.io/v2/

原文&#xff1a;https://www.cnblogs.com/sdgtxuyong/p/18647915 https://www.cnblogs.com/OneSeting/p/18532166 docker 换源&#xff0c;解决连接不上的问题。 编辑以下文件&#xff0c;不存在则创建&#xff1a; vim /etc/docker/daemon.json {"registry-mirrors&qu…...

DeepSeek助力文案,智能音箱如何改变你的生活?

你好&#xff0c;我是三桥君 你有没有为写智能音箱的宣传文案而抓耳挠腮过&#xff1f;三桥君在这方面可是有些感想&#xff0c;今天就来给你唠唠怎么用DeepSeek写出超赞的智能音箱宣传文案。 首先&#xff0c;你得给DeepSeek喂足“料”。这就好比做饭&#xff0c;你得准备好各…...