浙江网站建站/推广哪些app最挣钱

浙江网站建站,推广哪些app最挣钱,邢台网站开发,学校网站怎么建设视频今天分享一个比较有意思的案例 注意:因为原始SQL很长,为了方便排版,简化了SQL 下面SQL跑60秒才出结果,客户请求优化 select dtcs.owner, dtcs.table_name, dtcs.column_name, dct.commentsfrom dba_tab_columns dtcsleft outer j…

今天分享一个比较有意思的案例
注意:因为原始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系数据库中,列数据类型转换一定要小心小心再小心

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/899280.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

01 相机标定与相机模型介绍

学完本文,您将了解不同相机模型分类、内参意义,及对应的应用代码模型 标定的意义 建模三维世界点投影到二维图像平面的过程。标定输出的是相机模型。 相机模型 相机模型可以解理解为投影模型 +

Stereolabs ZED Box Mini:机器人与自动化领域的人工智能视觉新选择

在人工智能视觉技术快速发展的今天&#xff0c;其应用场景正在持续拓宽&#xff0c;从智能安防到工业自动化&#xff0c;从机器人技术到智能交通&#xff0c;各领域都在积极探索如何利用这一先进技术。而 Stereolabs 推出的ZED Box Mini&#xff0c;正是一款专为满足这些多样化…

K8S学习之基础五十九:部署gitlab服务

部署gitlab docker pull gitlab/gitlab-ce:latest docker tag gitlab/gitlab-ce:latest 172.16.80.140/gitlab/gitlab-ce:latest docker push 172.16.80.140/gitlab/gitlab-ce:latest docker run -d -p 443:443 -p 80:80 -p 222:22 --name gitlab --restart always -v /home/…

多线程 --- 多线程编程

在写代码的时候&#xff0c;可以使用多进程进行并发编程&#xff08;在Java中&#xff0c;不太推荐&#xff0c;很多很多关于进程相关的API&#xff0c;在Java标准库中&#xff0c;都没有提供&#xff09;&#xff0c;也可以使用多线程进行并发编程&#xff08;系统提供了多线程…

vue中上传接口file表单提交二进制文件流

1.使用elementui上传组件 要做一个选择文件后&#xff0c;先不上传&#xff0c;等最后点击确定后&#xff0c;把file二进制流及附加参数一起提交上去。 首先使用elementui中的上传组件&#xff0c;设置auto-uploadfalse&#xff0c;也就是选择文件后不立刻上传。 <el-uplo…

C++ map容器总结

map基本概念 简介&#xff1a; map中所有元素都是pair pair中第一个元素为key&#xff08;键值&#xff09;&#xff0c;起到索引作用&#xff0c;第二个元素为value&#xff08;实值&#xff09; 所有元素都会根据元素的键值自动排序 本质&#xff1a; map/multimap属于关…

【Zookeeper搭建(跟练版)】Zookeeper分布式集群搭建

&#xff08;一&#xff09;克隆前的准备 1. 用 xftp 发送文件 2. 时间同步&#xff1a; sudo cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime 3. zookpeeper 安装 部署 呼应开头发送的压缩包&#xff0c;解压&#xff1a; cd ~ tar -zxvf zookeeper-3.4.6.tar.g…

Flutter项目之页面实现以及路由fluro

目录&#xff1a; 1、项目代码结构2、页面编写以及路由配置main.dart(入口文件)page_content.dartindex.dart&#xff08;首页&#xff09;application.dart&#xff08;启动加载类&#xff09;pubspec.yaml&#xff08;依赖配置文件&#xff09;login.dart&#xff08;登录页&…

记录Jmeter 利用BeanShell 脚本解析JSON字符串

下载org.json包(文档说明) #下载地址 https://www.json.org/ # github 地址 https://github.com/stleary/JSON-java # api 文档说明 https://resources.arcgis.com/en/help/arcobjects-java/api/arcobjects/com/esri/arcgis/server/json/JSONObject.htmlBeanShell脚本 import…

uniapp动态循环表单校验失败:初始值校验

问题现象 &#x1f4a5; 在实现动态增减的单价输入表单时&#xff08;基于uv-form组件&#xff09;&#xff0c;遇到以下诡异现象&#xff1a; <uv-input>的v-model绑定初始值为数字类型时&#xff0c;required规则失效 ❌数字类型与字符串类型校验表现不一致 &#x1…

UML 图六种箭头含义详解:泛化、实现、依赖、关联、聚合、组合

目录 一、泛化&#xff08;Generalization&#xff09; 概念 表示方法 二、实现&#xff08;Realization&#xff09; 概念 表示方法 三、依赖&#xff08;Dependency&#xff09; 概念 表示方法 四、关联&#xff08;Association&#xff09; 概念 表示方法 五、…

Android Logcat总结

文章目录 Android Logcat总结日志格式过滤日志正向过滤反向过滤正则过滤日志等级 Android Logcat总结 日志格式 用法&#xff1a; Log.e("TAG", "hello") Log.i("TAG", "hello") Log.d("TAG", "hello")依次为&…

Unity UGUI - 六大基础组件

目录 一、Canvas上 1. Canvas&#xff1a;复制渲染子UI控件 2. ✨Canvas Scaler✨&#xff1a;画布分辨率自适应 3. Graphics Raycaster&#xff1a;射线事件响应 4. ✨Rect Transform✨&#xff1a;UI位置锚点对齐 二、Event System上 5. Event System 6. Standalone …

基于Springboot的网上订餐系统 【源码】+【PPT】+【开题报告】+【论文】

网上订餐系统是一个基于Java语言和Spring Boot框架开发的Web应用&#xff0c;旨在为用户和管理员提供一个便捷的订餐平台。该系统通过简化餐饮订购和管理流程&#xff0c;为用户提供快速、高效的在线订餐体验&#xff0c;同时也为管理员提供完善的后台管理功能&#xff0c;帮助…

从JVM底层揭开Java方法重载与重写的面纱:原理、区别与高频面试题突破

&#x1f31f;引言&#xff1a;一场由方法调用引发的"血案" 2018年&#xff0c;某电商平台在"双十一"大促期间遭遇严重系统故障。 技术团队排查发现&#xff0c;问题根源竟是一个继承体系中的方法重写未被正确处理&#xff0c;导致订单金额计算出现指数级…

qt QQuaternion详解

1. 概述 QQuaternion 是 Qt 中用于表示三维空间中旋转的四元数类。它包含一个标量部分和一个三维向量部分&#xff0c;可以用来表示旋转操作。四元数在计算机图形学中广泛用于平滑的旋转和插值。 2. 重要方法 默认构造函数 QQuaternion::QQuaternion(); // 构造单位四元数 (1…

Nginx相关漏洞解析

一、CRLF注入漏洞 原理&#xff1a;Nginx将传入的url进行解码&#xff0c;对其中的%0a%0d替换成换行符&#xff0c;导致后面的数据注入至头部&#xff0c;造成CRLF 注入漏洞 1、开环境 2、访问网站&#xff0c;并抓包 3、构造请求头 %0ASet-cookie:JSPSESSID%3D1 这样就可以…

RUBY报告系统

我们常用GFP及其变体如RFP、YFP、mCherry等作为基因表达的报告蛋白——需要荧光显微镜制片观察&#xff1b;此外还有GUS或荧光素酶作为报告酶——需要添加底物。 RUBY报告系统则与众不同&#xff0c;其作用原理是&#xff1a;将酪氨酸转化为鲜艳的红色甜菜碱&#xff0c;无需使…

office_word中使用宏以及DeepSeek

前言 Word中可以利用DeepSeek来生成各种宏&#xff0c;从而生成我们需要各种数据和图表&#xff0c;这样可以大大减少我们手工的操作。 1、Office的版本 采用的是微软的office2016&#xff0c;如下图&#xff1a; 2、新建一个Word文档 3、开启开发工具 这样菜单中的“开发工具…

【踩坑系列】使用httpclient调用第三方接口返回javax.net.ssl.SSLHandshakeException异常

1. 踩坑经历 最近做了个需求&#xff0c;需要调用第三方接口获取数据&#xff0c;在联调时一直失败&#xff0c;代码抛出javax.net.ssl.SSLHandshakeException异常&#xff0c; 具体错误信息如下所示&#xff1a; javax.net.ssl.SSLHandshakeException: sun.security.validat…