-
Notifications
You must be signed in to change notification settings - Fork 225
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
jit cannot turned off for single query #1700
Comments
Which version are you using? The above works just fine in 5.0. |
I'm using .NET 5 with latest packages (5.0.3) |
Here's my code where it works: await using var ctx = new BlogContext();
await ctx.Database.EnsureDeletedAsync();
await ctx.Database.EnsureCreatedAsync();
_ = await ctx.Blogs.FromSqlRaw(@"SET jit TO on; SELECT * FROM ""Blogs""; SET jit TO off").ToListAsync();
public class BlogContext : DbContext
{
public DbSet<Blog> Blogs { get; set; }
static ILoggerFactory ContextLoggerFactory
=> LoggerFactory.Create(b => b.AddConsole().AddFilter("", LogLevel.Information));
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
=> optionsBuilder
.UseNpgsql(@"Host=localhost;Username=test;Password=test")
.EnableSensitiveDataLogging()
.UseLoggerFactory(ContextLoggerFactory);
}
public class Blog
{
public int Id { get; set; }
public string Name { get; set; }
} |
Context contains class Toode and subclass TooteInfo without additions:
DbContext contains:
Command which causes exception:
Postgres error:
|
This is specifically happening because you're querying a non-root type in the hierarchy. If it's acceptable to query the hierarchy root, that will work. Opened dotnet/efcore#24157 to track on the EF side. |
Duplicate of dotnet/efcore#24157 |
Another option is to send set the JIT option outside of the raw query, though that would add roundtrips. Finally, you can just wrap the whole thing in a PG function. |
To reproduce, run
await ctx.Students.FromSqlRaw("set jit to off;select * from student; set jit to on").ToListAsync();
This causes syntax error since query is wrapped to subselect.
As discussed in pgsql-general mailing list, jit causes some queries to run very slowly. It should be possible to jit off for specific query.
The text was updated successfully, but these errors were encountered: