Here's where things get interesting:
now things have flipped around!
billdate = 1 is SLOWER than billdate = any other value
# explain select s.id from subaccounts s, accounts a where a.id = s.idaccount and a.billdate = 2;
NOTICE: QUERY PLAN:
Nested Loop (cost=0.00..16.42 rows=2 width=12)
-> Index Scan using idxaccountbilldate on accounts a (cost=0.00..2.02 rows=1 width=4)
-> Index Scan using idxsubprimary on subaccounts s (cost=0.00..14.22 rows=15 width=8)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# explain select s.id from subaccounts s, accounts a where a.id = s.idaccount and a.billdate = 1;
NOTICE: QUERY PLAN:
Hash Join (cost=79.83..310.33 rows=3506 width=12)
-> Seq Scan on subaccounts s (cost=0.00..71.10 rows=3510 width=8)
-> Hash (cost=76.03..76.03 rows=1520 width=4)
-> Seq Scan on accounts a (cost=0.00..76.03 rows=1520 width=4)
-----------------------------------------------------------------------------
david@backpack.com BackPack Software, Inc. www.backpack.com
+1 651.645.7550 voice "Life is an Adventure.
+1 651.645.9798 fax Don't forget your BackPack!"
-----------------------------------------------------------------------------