Different datatypes different execution plans bitmap scan vs index scan POSTGRESQL
You’re asking why the two queries with the WHERE id &lt; 423 clause have different query plans correct?
Well the type of scan used is dependent on the actual characteristics of the table. Your first table uses a serial so it increments by 1 and there are only 423 rows to get so an index scan is most efficient. In your second example there you use a numeric and multiply that by a random so there are potentially quite a few rows in that filter and PG decides an index scan will not be most efficient.
TL;DR even though these queries and table properties look similar, your tables’ data is actually quite different.