Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Force TOAST to be used by the PostgreSQL table #17

Open
chrisdone opened this issue Jul 24, 2021 · 0 comments
Open

Force TOAST to be used by the PostgreSQL table #17

chrisdone opened this issue Jul 24, 2021 · 0 comments
Labels
enhancement New feature or request

Comments

@chrisdone
Copy link
Member

While researching TOAST I found this very interesting article: The Surprising Impact of Medium-Size Texts on PostgreSQL Performance

Screenshot:

Screenshot from 2021-07-24 21-51-30

This includes when indexes are used.

The takeaway is:

  • If you have lots of small fields <2KB, then pulling rows from your table will be fast and should not use TOAST.
  • If you have lots of big fields, TOAST will perform much better when selecting specific rows from tables.
  • If you have a mixture of small and big fields, you're better off configuring the tuple setting to force PG to TOAST strings more aggressively:

toast_tuple_target is a storage parameter that controls the minimum tuple length after which PostgreSQL tries to move long values to TOAST. The default is 2K, but it can be decreased to a minimum of 128 bytes. The lower the target, the more chances are for a medium size string to be move out-of-line to the TOAST table.

In the case of Casa, we have a mixture of large and small fields. Hypothetically we could achieve a performance boost by configuring this and pushing out all our blobs into TOAST. Casa regularly performs queries of the form select content from blob where id in (x, y, z, ...). But we'd need to run some SQL queries to group by content size to see what the size distributions are like.

If we get some query time metrics from Prometheus, that could be a way to measure the improvement. Could make a decent blog post.

@chrisdone chrisdone added the enhancement New feature or request label Jul 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant