BraisonCrece

BraisonCrece

High Performance PostgreSQL for Rails: users count inconsistency (page 56)

Hi @andatki! First of all, thank you so much for this amazing book! :muscle:

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 :sweat_smile:), because the book expects the users table to contain only 20200 records (the ones added with therails 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

andatki

Author of High Performance PostgreSQL for Rails

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

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 :sweat_smile:.

What I confirm is that this can be found in the block titled “Understanding Clone and Replace Trade-Offs”.

Popular Prag Prog topics Top

ianwillie
Hello Brian, I have some problems with running the code in your book. I like the style of the book very much and I have learnt a lot as...
New
yulkin
your book suggests to use Image.toByteData() to convert image to bytes, however I get the following error: "the getter ‘toByteData’ isn’t...
New
lirux
Hi Jamis, I think there’s an issue with a test on chapter 6. I own the ebook, version P1.0 Feb. 2019. This test doesn’t pass for me: ...
New
Chrichton
Dear Sophie. I tried to do the “Authorization” exercise and have two questions: When trying to plug in an email-service, I found the ...
New
leba0495
Hello! Thanks for the great book. I was attempting the Trie (chap 17) exercises and for number 4 the solution provided for the autocorre...
New
brian-m-ops
#book-python-testing-with-pytest-second-edition Hi. Thanks for writing the book. I am just learning so this might just of been an issue ...
New
akraut
The markup used to display the uploaded image results in a Phoenix.LiveView.HTMLTokenizer.ParseError error. lib/pento_web/live/product_l...
New
creminology
Skimming ahead, much of the following is explained in Chapter 3, but new readers (like me!) will hit a roadblock in Chapter 2 with their ...
New
New
ggerico
I got this error when executing the plot files on macOS Ventura 13.0.1 with Python 3.10.8 and matplotlib 3.6.1: programming_ML/code/03_...
New

Other popular topics Top

Rainer
My first contact with Erlang was about 2 years ago when I used RabbitMQ, which is written in Erlang, for my job. This made me curious and...
New
AstonJ
There’s a whole world of custom keycaps out there that I didn’t know existed! Check out all of our Keycaps threads here: https://forum....
New
dimitarvp
Small essay with thoughts on macOS vs. Linux: I know @Exadra37 is just waiting around the corner to scream at me “I TOLD YOU SO!!!” but I...
New
Exadra37
Oh just spent so much time on this to discover now that RancherOS is in end of life but Rancher is refusing to mark the Github repo as su...
New
New
OvermindDL1
Woooooooo! This is such a huge release for it, and 2 years incoming! In short, the library is now using an updated hyper backend (not j...
New
Maartz
Hi folks, I don’t know if I saw this here but, here’s a new programming language, called Roc Reminds me a bit of Elm and thus Haskell. ...
New
New
CommunityNews
A Brief Review of the Minisforum V3 AMD Tablet. Update: I have created an awesome-minisforum-v3 GitHub repository to list information fo...
New
AstonJ
This is a very quick guide, you just need to: Download LM Studio: https://lmstudio.ai/ Click on search Type DeepSeek, then select the o...
New

Latest in PragProg

View all threads ❯