ossc-db / pg_hint_plan

Extension adding support for optimizer hints in PostgreSQL
Other
710 stars 103 forks source link

Add EXPLAIN options (COSTS false) for some tests #148

Closed mikecaat closed 1 year ago

mikecaat commented 1 year ago

The commit adds the EXPLAIN OPTION '(COSTS false)' for test stability, because some tests don't need to check the costs.

make installcheck is failed after https://github.com/postgres/postgres/commit/d37ab378b6e773c278c14b9554a1ea23b355aab9 is committed because the costs is changed. (Might this only happen in my environment?)

diff -U3 /home/ikedamsh/repos/psql/extension/pg_hint_plan/expected/ut-A.out /home/ikedamsh/repos/psql/extension/pg_hint_plan/results/ut-A.out
--- /home/ikedamsh/repos/psql/extension/pg_hint_plan/expected/ut-A.out  2023-08-25 15:35:53.393621985 +0900
+++ /home/ikedamsh/repos/psql/extension/pg_hint_plan/results/ut-A.out   2023-08-25 15:36:43.473621489 +0900
@@ -4789,7 +4789,7 @@
 EXPLAIN EXECUTE p1;
                       QUERY PLAN                      
 ------------------------------------------------------
- Seq Scan on tpc  (cost=0.00..17.50 rows=333 width=4)
+ Seq Scan on tpc  (cost=0.00..20.50 rows=333 width=4)
    Filter: (a < 999)
 (2 rows)

@@ -4803,7 +4803,7 @@

                                QUERY PLAN                               
 ------------------------------------------------------------------------
- Index Scan using tpc_a_idx on tpc  (cost=0.28..34.10 rows=333 width=4)
+ Index Scan using tpc_a_idx on tpc  (cost=0.28..46.10 rows=333 width=4)
    Index Cond: (a < 999)
 (2 rows)

@@ -4817,7 +4817,7 @@

                      QUERY PLAN                     
 ----------------------------------------------------
- Seq Scan on tpc  (cost=0.00..17.50 rows=5 width=4)
+ Seq Scan on tpc  (cost=0.00..20.50 rows=5 width=4)
    Filter: (a = 500)
 (2 rows)

@@ -4828,7 +4828,7 @@
 EXPLAIN EXECUTE p1;
                       QUERY PLAN                      
 ------------------------------------------------------
- Seq Scan on tpc  (cost=0.00..17.50 rows=333 width=4)
+ Seq Scan on tpc  (cost=0.00..20.50 rows=333 width=4)
    Filter: (a < 999)
 (2 rows)

@@ -4842,7 +4842,7 @@

                                QUERY PLAN                               
 ------------------------------------------------------------------------
- Index Scan using tpc_a_idx on tpc  (cost=0.28..34.10 rows=333 width=4)
+ Index Scan using tpc_a_idx on tpc  (cost=0.28..46.10 rows=333 width=4)
    Index Cond: (a < 999)
 (2 rows)

@@ -4856,7 +4856,7 @@

                      QUERY PLAN                     
 ----------------------------------------------------
- Seq Scan on tpc  (cost=0.00..17.50 rows=5 width=4)
+ Seq Scan on tpc  (cost=0.00..20.50 rows=5 width=4)
    Filter: (a = 500)
 (2 rows)

Although only ut-A is failed on my laptop, I also fix ut-T because I have found that it can cause the same problem with the following query.

$ grep -r "cost="  | grep -v "cost=x" | grep -v "cost={inf"
mikecaat commented 1 year ago

BTW, the costs changed because the number of relpages is changed in my laptop. It seems reasonable because the commit changes the logic of extending relation.

# One commit before postgres/postgres@d37ab37
=# SELECT relpages FROM pg_class WHERE relname = 'tpc';
 relpages 
----------
        5
(1 row)

# postgres/postgres@d37ab37
=# SELECT relpages FROM pg_class WHERE relname = 'tpc';
 relpages
----------
        8
(1 row)
michaelpq commented 1 year ago

Okay, thanks for this one. Applied down to 11, even if the difference only showed up on HEAD.