Gregory Wood wrote:
explain select * from a where x=3;

PostgreSQL is treating 3 as an int4 (integer) type, whereas x is an int2
(smallint) type. Try casting the constant as a smallint and it should use
the index:

explain select * from a where x=3::smallint;

Aha! šGreat! Thanks a lot! That worked!
Now, the next problem:

explain select count (x) from a ;

Aggregateš (cost=100175934.05..100175934.05 rows=1 width=2)
š ->š Seq Scan on aš (cost=100000000.00..100150659.04 rows=10110004 width=2)

Am I missing something here again, or will it just not use an index for aggregation?

I mean, especially an this case, it looks so weird that it KNOWS the answer to my query RIGHT AWAY (rows=... in the explain response), yet it takes it so long to return it...