Thanks for the replies Jeff, Tom and Merlin. Pages that SELECT multiple rows with OFFSET and LIMIT conditions struggle to top 1.3k req/s Yes — 0 (OFFSET) and 16 (LIMIT), or 15 and 31 (i.e. “second page” of results). There’s no difference on that front. For context, OFFSET is a multiple of 15 (i.e. 15 results per page) and LIMIT is always 15 + 1 in an attempt to fetch one more result, get the len of the returned slice and then return paginate true + slice the last result off if there’s more than 15. The query in question is: http://explain.depesz.com/s/7g8 and the table schema is as below: - Testing SELECT * FROM … with just LIMIT 15 and no offset yields 1299 request/s at the front end of the application. - Testing SELECT id, title, company, location, commute, term, expiry_date (a subset of fields) with LIMIT 15 and no OFFSET yields 1800 request/s at the front end. There’s definitely an increase to be realised there (I’d say by just tossing the rendered HTML field). Based on your comments about the Go side of things, I ran a quick test by cutting the table down to 6 records from the 39 in the test DB in all previous tests. This skips the pagination logic (below) and yields 3068 req/s on the front-end. // Determine if we have more than one page of results. // If so, trim the extra result off and set pagination = true if len(listings) > opts.PerPage { paginate = true listings = listings[:opts.PerPage] } So there certainly appears to be a bottleneck on the Go side as well (outside of even the DB driver), probably from the garbage generated from slicing the slice, although I’d be keen to know if there’s a better way to approach returning a paginated list of results. Well, you can also do client side pagination using the row-wise What would be a better approach here? The cursor approach isn’t ideal in my case (although I could make it work), but what other options are there that are stateless?
Noted — thanks. |