Hello,
I noticed a poor performance when querying a single record. I hope it's not due to my configuration, so could I ask you to first check your postgres log with "log_statement = all"? Does postgres query the primary key like this?
"_r0"."id" = $1::FLOAT8
This prevents postgres from using the index:
-> Parallel Seq Scan on table _r0 (cost=0.00..1341226.31 rows=8271 width=378) (actual time=1421.943..1428.742 rows=0 loops=8)
Filter: ((id)::double precision = '24335523'::double precision)
When I debug the passed variables in the code, filter.Side1 is seen as !s(float64=2.4335523e+07)}, so querying a table by primary key ends up in the float64 case block in data_get.go, casting it to FLOAT8 for postgres. Preventing this for numerics without decimal place, lets postgres handle the id as expected.
case float64: // short alias to double precision, float64 is default coming from JSON decode of JS number values
if math.Mod(s.Value.(float64), 1.0) == 0 {
return fmt.Sprintf("$%d", len(*queryArgs)), nil
} else {
return fmt.Sprintf("$%d::FLOAT8", len(*queryArgs)), nil
}
(Code only for validating the above assumption, probably not suitable as a patch.)
Thank you for your review.
Martin