-
-
Notifications
You must be signed in to change notification settings - Fork 253
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
Schema generation performance and documentation #287
Comments
If you know that your code changes don't require a new schema, you can do, for example Caching .sql files to avoid generation isn't really a thing with how the new schema generator works. Because the schema generator now uses fully-resolved rust types, the generation is compiled into the .so itself (and then statically linked to the binary sql-generator). It's no longer an external process that simply analyzes the source code.
Or you can run |
--no-schema does not speed things up. Note the "28.91s" below. It hangs on the line
|
hmm.
Let me investigate. |
I think maybe what's happening here is that the generic I think maybe with |
Yeah, that was it! I did properly push down the $ touch src/lib.rs; cargo pgx test --no-schema pg12
"cargo" "test" "--features" " pg12 pg_test" "--no-default-features" "--lib"
Compiling foo v0.0.0 (/Users/e_ridge/foo/foo)
Finished test [unoptimized + debuginfo] target(s) in 2.65s
Running unittests (target/debug/deps/foo-1904fb65e39f27b5)
running 1 test
building extension with features `pg12 pg_test`
"cargo" "build" "--lib" "--features" "pg12 pg_test" "--no-default-features"
Compiling foo v0.0.0 (/Users/e_ridge/foo/foo)
Finished dev [unoptimized + debuginfo] target(s) in 2.15s
installing extension
Copying control file to `/Users/e_ridge/.pgx/12.8/pgx-install/share/postgresql/extension/foo.control`
Copying shared library to `/Users/e_ridge/.pgx/12.8/pgx-install/lib/postgresql/foo.so`
Skipping schema generation
Finished installing foo
test tests::pg_test_hello_foo ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 3.20s
Stopping Postgres I'll publish a 0.2.4 here in a few minutes and you can tell me if it's better. |
I think we should just always use Looks like you can get yourself into trouble with this sequence tho: $ cargo pgx run pg12
$ cargo pgx test --no-schema pg12 The latter will re-use the schema generated by the former, which means it won't have the test-specific schema. But I feel like that's on the user at that point. |
Soon as CI passes I'll publish a new release. In an hour or so. |
I'll look at it right away. |
v0.2.4 is live on crates.io. Remember to |
Did
Total success. Then, I made a tiny source code change and ran it again:
That took 11 seconds, which is way better than 30 seconds+. Then, I added another [pg_extern] function, which forced a schema change:
Now we're back up to 30 seconds. All in all, 0.2.x is now usable, but still way slower than 0.1.x if you make a schema change. Thanks, I'm back in business. |
Yeah. But it's at least way more correct and flexible than 0.1.x. I suspect we'll find ways to make it faster or at least smarter about when a schema generation is necessary, but none of that is clear at the moment. Now that Rust's incremental compiler is actually live and working correctly, it makes what we're doing with the schema generator pretty tough. There might be some tricks we can play with |
Maybe I should reopen this, so we have an open request. 30 seconds for every edit/compile/test cycle makes it hard to get work done. Santa did not give me a $5,000 Threadripper this year. I'm stuck with an ordinary machine. |
Replaced by #391 |
Prior to version 0.2, schema generation for functions, types, etc. was quite fast, and you could examine the generated .sql files to see what pgx was doing under the hood.
The new schema generation code is very slow. Now running a basic test takes 30+ seconds.
Plus, it's not obvious where to look to see the generated .sql. (It looks like .pgx/13.4/pgx-install/share/postgresql/extension/my_extension.sql). Having it in the project itself would be a lot more convenient.
I wonder if we could kill two birds with one stone? Cache the .sql files in the project itself and avoid the generation phase for files that have not changed.
Update: I see that "cargo pgx schema" creates the file in /sql. Maybe that should happen by default.
The text was updated successfully, but these errors were encountered: