The filter isn't very selective, so postgres should be very happy to use an index for the sort. An index on maasserver_event(node_id, id) will probably get you the latest 50 in <200ms cold.
If you want a COUNT you're out of luck without faster IO (or more RAM), but a COUNT doesn't sound very useful here.
The filter isn't very selective, so postgres should be very happy to use an index for the sort. An index on maasserver_ event(node_ id, id) will probably get you the latest 50 in <200ms cold.
If you want a COUNT you're out of luck without faster IO (or more RAM), but a COUNT doesn't sound very useful here.