Use prepared statements for readonly extraction

These statements don't involve the temp tables so are
identical in the writable and readonly apidb backends.