So what happens if query the table directly?:
select * from wf.workflow where head_table_id::float8::int8 = 25408438504;
vs
select * from wf.workflow where head_table_id = 25408438504;
Both return lots of rows. The same number of rows.
count|
-----+
62260|
select count(*) from wf.workflow where head_table_id = 25408438504;
count|-----+
62260|
Both of them use seq scan.
QUERY PLAN |
-------------------------------------------------------------------+
Aggregate (cost=2985.00..2985.01 rows=1 width=8) |
-> Seq Scan on workflow (cost=0.00..2829.07 rows=62369 width=0)|
Filter: (head_table_id = '25408438504'::bigint) |
-------------------------------------------------------------------+
Aggregate (cost=2985.00..2985.01 rows=1 width=8) |
-> Seq Scan on workflow (cost=0.00..2829.07 rows=62369 width=0)|
Filter: (head_table_id = '25408438504'::bigint) |
QUERY PLAN |
-------------------------------------------------------------------------------------+
Aggregate (cost=3289.86..3289.87 rows=1 width=8) |
-> Seq Scan on workflow (cost=0.00..3288.70 rows=460 width=0) |
Filter: (((head_table_id)::double precision)::bigint = '25408438504'::bigint)|
-------------------------------------------------------------------------------------+
Aggregate (cost=3289.86..3289.87 rows=1 width=8) |
-> Seq Scan on workflow (cost=0.00..3288.70 rows=460 width=0) |
Filter: (((head_table_id)::double precision)::bigint = '25408438504'::bigint)|