-
Notifications
You must be signed in to change notification settings - Fork 312
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
Experiment: Support for creating unlogged tables to speed up tests #601
base: master
Are you sure you want to change the base?
Conversation
It would be nice if people could post |
@@ -1168,7 +1168,9 @@ if Code.ensure_loaded?(Postgrex) do | |||
table_name = quote_name(table.prefix, table.name) | |||
|
|||
query = [ | |||
"CREATE TABLE ", | |||
"CREATE ", | |||
if_do(table.unlogged, "UNLOGGED "), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note for the future: we should probably call this "table.modifier" or something, because there are other options, such as temporary tables in MySQL, global/local, etc. It should be a plain string.
All test runs logged this. Some had
My project is maybe too small to properly measure these effects. It has 11 tables, 2 of which are |
I tried using unlogged tables some time ago on a project I no longer have access to. It had around 400 tests, and the improvement seemed to be about 10% / 1.5 seconds. |
This wont work for those of us who use Before
After
|
Here are the results on Felt's codebase, running on my M1 MacBook Air. I've included our tests tagged
Mean total runtime: 134.9 before, 125.9 seconds after, for a speedup in the range of 7%. If there's interest, I'd be happy to run these overnight to get something closer to a statistically significant sample. (The variance on the "before" number in particular is a little weird to me.) I could also run it on an Intel Mac. UPDATE: Here are the results of running
Thus, there was very little difference on our "fast" tests, and a savings of about 5% on the full suite. |
for me, tldr, ~8% faster async runs, ~3% slower sync runs, but overall 2% improvement if you are looking at the clock (real time). Setup: In order to do this, since I'm using markdown
|
As mentioned in some previous comments, getting
|
I didn’t have the time to run the test multiple times, so I executed it one time before and one time after the change. I have 7951 tests, many of which are LiveView tests. From 362 to 353, about a 2.3% improvement in the value informed by ExUnit.
|
This seems useful to me even if it makes tests slower. It is a feature of Postres so they had something in mind when they created it. And other people might discover their own uses outside of that. But like Jose said it's better if it's generalized to a string because all these modifiers exist:
edit: oh I see you want to make a repo configuration too. then the test performance makes sense |
I agree we should support it as an option and as a string. I am not convinced on the repo configuration, given there is no meaningful gain, but perhaps we could introduce an option called |
If I understand correctly, this would mean adding a new option to In that case, how should it be called? For the reference - in Postgres docs it appears as Parameters, however Mysql and SQLlite don't give any name to that particular part of the create statement, they just call those options "keywords". Example from Sqllite:
The current options in
We already have
What do you think? |
|
I'm curious to hear from folks about the impact and whether it's worth adding such a feature at all.
If you want to try it on your codebase, follow these steps:
test.exs
file, add the following configuration: