ysqlsh (11.2-YB-2.1.6.0-b0) Type "help" for help. yugabyte_ware_3nodes_2=# EXPLAIN (ANALYZE, BUFFERS) SELECT * FROM a1 WHERE f_id_1 = 'fc12ef23-27f3-43d9-8c85-30e50d694b1c' OR f_id_2 = 'fc12ef23-27f3-43d9-8c85-30e50d694b1c'; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------ Foreign Scan on association (cost=0.00..105.00 rows=1000 width=56) (actual time=81816.510..81816.511 rows=0 loops=1) Filter: ((f_id_1 = 'fc12ef23-27f3-43d9-8c85-30e50d694b1c'::uuid) OR (f_id_2 = 'fc12ef23-27f3-43d9-8c85-30e50d694b1c'::uuid)) Rows Removed by Filter: 7052719 Planning Time: 28.274 ms Execution Time: 81818.253 ms (5 rows) yugabyte_ware_3nodes_2=# CREATE INDEX a1_f_id_1_idx ON a1 USING btree (f_id_1); NOTICE: index method "btree" was replaced with "lsm" in YugabyteDB CREATE INDEX yugabyte_ware_3nodes_2=# EXPLAIN (ANALYZE, BUFFERS) SELECT * FROM a1 WHERE f_id_1 = 'fc12ef23-27f3-43d9-8c85-30e50d694b1c' OR f_id_2 = 'fc12ef23-27f3-43d9-8c85-30e50d694b1c'; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------ Foreign Scan on association (cost=0.00..105.00 rows=1000 width=56) (actual time=78753.000..78753.001 rows=0 loops=1) Filter: ((f_id_1 = 'fc12ef23-27f3-43d9-8c85-30e50d694b1c'::uuid) OR (f_id_2 = 'fc12ef23-27f3-43d9-8c85-30e50d694b1c'::uuid)) Rows Removed by Filter: 7052719 Planning Time: 4.563 ms Execution Time: 78753.136 ms (5 rows) yugabyte_ware_3nodes_2=# CREATE INDEX a1_f_id_2_idx ON a1 USING btree (f_id_2); NOTICE: index method "btree" was replaced with "lsm" in YugabyteDB CREATE INDEX yugabyte_ware_3nodes_2=# EXPLAIN (ANALYZE, BUFFERS) SELECT * FROM a1 WHERE f_id_1 = 'fc12ef23-27f3-43d9-8c85-30e50d694b1c' OR f_id_2 = 'fc12ef23-27f3-43d9-8c85-30e50d694b1c'; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------ Foreign Scan on association (cost=0.00..105.00 rows=1000 width=56) (actual time=78976.661..78976.662 rows=0 loops=1) Filter: ((f_id_1 = 'fc12ef23-27f3-43d9-8c85-30e50d694b1c'::uuid) OR (f_id_2 = 'fc12ef23-27f3-43d9-8c85-30e50d694b1c'::uuid)) Rows Removed by Filter: 7052719 Planning Time: 4.692 ms Execution Time: 78976.729 ms (5 rows) yugabyte_ware_3nodes_2=# analyze a1; WARNING: analyzing non-temporary tables will be ignored ANALYZE yugabyte_ware_3nodes_2=# EXPLAIN (ANALYZE, BUFFERS) SELECT * FROM a1 WHERE f_id_1 = 'fc12ef23-27f3-43d9-8c85-30e50d694b1c' OR f_id_2 = 'fc12ef23-27f3-43d9-8c85-30e50d694b1c'; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------ Foreign Scan on association (cost=0.00..105.00 rows=1000 width=56) (actual time=76703.954..76703.955 rows=0 loops=1) Filter: ((f_id_1 = 'fc12ef23-27f3-43d9-8c85-30e50d694b1c'::uuid) OR (f_id_2 = 'fc12ef23-27f3-43d9-8c85-30e50d694b1c'::uuid)) Rows Removed by Filter: 7052719 Planning Time: 0.071 ms Execution Time: 76704.051 ms (5 rows)