
BraisonCrece
High Performance PostgreSQL for Rails: users count inconsistency (page 56)
Hi @andatki! First of all, thank you so much for this amazing book!
I’ve found something that can cause a bit of confusion.
After seeding the data in order and running the bulk_load
script, the reader will have about 10M rows in the users table. But on page 56, after running the first statement to copy the scrubbed data into the users_copy
table, the operation will fail because of the statement timeout (at least on my computer ), because the book expects the users table to contain only 20200 records (the ones added with the
rails data_generators:generate_all
), but as I mentioned there are about 10M.
This shouldn’t be a problem for the majority of readers, but it can cause confusion and breaks the consistency a bit.
Most Liked

andatki
Hi @BraisonCrece. Thanks for posting this. The statement_timeout
is used to set the max allowed time for operations to run before they’re cancelled.
What we need to do there is raise the statement_timeout
to allow for more time. We can do that in several ways: by modifying the user’s persistent value, by modifying it within a psql session, or modifying it only for the scope of a single transaction. If you used the Rideshare scripts to create the owner or app_user users, you could modify them with a statement like this one:
ALTER ROLE owner SET statement_timeout = '60s';
That would raise the statement timeout to 60 seconds on an ongoing basis. You may need to raise it even more. You can also set it back later if you’d like.
You can also raise the statement timeout within a session:
SET statement_timeout = '60s';
Or you can scope the change to an individual transaction using the LOCAL
keyword. To do that, use SET LOCAL
as follows:
SET LOCAL statement_timeout = '60s';
With the bigger row count table where operations are taking longer, try raising the statement timeout and performing the operation, and letting me know if that fixes it for you.
Thanks!

BraisonCrece
I would say I have the latest version, I downloaded the copy last week.
I cannot confirm what page is because depending on the width of the reader (apple books) the page number is different .
What I confirm is that this can be found in the block titled “Understanding Clone and Replace Trade-Offs”.
Popular Prag Prog topics










Other popular topics










Latest in PragProg
Latest (all)
Categories:
Popular Portals
- /elixir
- /rust
- /wasm
- /ruby
- /erlang
- /phoenix
- /keyboards
- /js
- /rails
- /python
- /security
- /go
- /swift
- /vim
- /clojure
- /java
- /haskell
- /emacs
- /svelte
- /onivim
- /typescript
- /crystal
- /c-plus-plus
- /tailwind
- /kotlin
- /gleam
- /react
- /flutter
- /elm
- /ocaml
- /vscode
- /opensuse
- /ash
- /centos
- /php
- /deepseek
- /zig
- /scala
- /html
- /debian
- /nixos
- /lisp
- /agda
- /textmate
- /sublime-text
- /react-native
- /kubuntu
- /arch-linux
- /ubuntu
- /revery
- /manjaro
- /django
- /spring
- /diversity
- /nodejs
- /lua
- /julia
- /slackware
- /c
- /neovim