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 Pragmatic Bookshelf topics Top

abtin
page 20: … protoc command… I had to additionally run the following go get commands in order to be able to compile protobuf code using go...
New
jon
Some minor things in the paper edition that says “3 2020” on the title page verso, not mentioned in the book’s errata online: p. 186 But...
New
belgoros
Following the steps described in Chapter 6 of the book, I’m stuck with running the migration as described on page 84: bundle exec sequel...
New
mikecargal
Title: Hands-On Rust (Chapter 11: prefab) Just played a couple of amulet-less games. With a bit of debugging, I believe that your can_p...
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
digitalbias
Title: Build a Weather Station with Elixir and Nerves: Problem connecting to Postgres with Grafana on (page 64) If you follow the defau...
New
brunogirin
When trying to run tox in parallel as explained on page 151, I got the following error: tox: error: argument -p/–parallel: expected one...
New
s2k
Hi all, currently I wonder how the Tailwind colours work (or don’t work). For example, in app/views/layouts/application.html.erb I have...
New
New

Other popular topics Top

ohm
Which, if any, games do you play? On what platform? I just bought (and completed) Minecraft Dungeons for my Nintendo Switch. Other than ...
New
dasdom
No chair. I have a standing desk. This post was split into a dedicated thread from our thread about chairs :slight_smile:
New
AstonJ
Just done a fresh install of macOS Big Sur and on installing Erlang I am getting: asdf install erlang 23.1.2 Configure failed. checking ...
New
Margaret
Hello content creators! Happy new year. What tech topics do you think will be the focus of 2021? My vote for one topic is ethics in tech...
New
mafinar
Crystal recently reached version 1. I had been following it for awhile but never got to really learn it. Most languages I picked up out o...
New
rustkas
Intensively researching Erlang books and additional resources on it, I have found that the topic of using Regular Expressions is either c...
New
AstonJ
Saw this on TikTok of all places! :lol: Anyone heard of them before? Lite:
New
foxtrottwist
A few weeks ago I started using Warp a terminal written in rust. Though in it’s current state of development there are a few caveats (tab...
New
PragmaticBookshelf
Rails 7 completely redefines what it means to produce fantastic user experiences and provides a way to achieve all the benefits of single...
New
First poster: bot
Large Language Models like ChatGPT say The Darnedest Things. The Errors They MakeWhy We Need to Document Them, and What We Have Decided ...
New

Sub Categories: