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

Option to set JIT = off? #422

Open
emptyflask opened this issue Aug 23, 2024 · 2 comments
Open

Option to set JIT = off? #422

emptyflask opened this issue Aug 23, 2024 · 2 comments

Comments

@emptyflask
Copy link

I have a massive ~1000 line materialized view that takes the Postgres JIT about 7 seconds to do its thing, while the execution itself (on a small table, anyway) is maybe a half second. Since I need to refresh the views in my test suite, I just set JIT = off globally in the test environment, but it would be nice if there was a built-in option to disable it for the view only.

If I write it, would this be a welcome change?

@derekprior
Copy link
Contributor

derekprior commented Aug 23, 2024

If I write it, would this be a welcome change?

My gut reaction is "no." Is this exposed in ActiveRecord at all? If I had an app that wanted this behavior I'd likely introduce something like:

def without_pg_jit(&block)
  # turn off jit
  yield
ensure
  # turn on jit
end

Seems unlikely or at least not common to only experience an issue with JIT within Scenic so I'm hesitant to account for it here.

@emptyflask
Copy link
Author

I don't believe it's exposed anywhere in Rails, for now I just do this in my test_helper.

ActiveRecord::Base.connection.execute("SET jit = off")

It would be convenient to have a built-in option, but you're right that it's not too difficult to just disable it in the migrations and anywhere else where a refresh is needed.

It might be worth a note in the documentation, since I assume most materialized views are doing some complex heavy lifting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants