You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, coming from a previous version of npgsql EF Core (2.2), I noticed the following change regarding executed query logging.
Given the following code:
// Enable sensitive data logging: will log the queries and the parameters too.protectedoverridevoidOnConfiguring(DbContextOptionsBuilderbuilder)=>builder.EnableSensitiveDataLogging();[...]
var ids=newint[]{1,2,3};varx=_context.Blogs.Where(b =>ids.Contains(b.Id)).ToList();
With the previous version I was getting the following log, where the ids values were not parameterized, but they were clearly visible:
Executed DbCommand (3ms) [Parameters=[], CommandType='Text']
SELECTb.nameFROM blogs AS b
WHEREb.idIN (1, 2, 3)
Now with npgsql EF Core 5.0 I'm getting this log:
Executed DbCommand (11ms) [Parameters=[@__ids_0='System.Int32[]' (DbType = Object)], CommandType='Text']
SELECTb.nameFROM blogs AS b
WHEREb.id= ANY (@__ids_0)
The generated SQL is fine, even better because ids are now parameterized, but their value is not visible anymore, making harder to run the query manually for debugging purposes.
Is there a way to get the contents of the ids array in the "Parameters" section of the log?
Is this a regression or is by design?
Thank you!
The text was updated successfully, but these errors were encountered:
@Xayton this isn't a regression - in fact it's an improvement in how the Npgsql EF provider translates your LINQ query. The previous translation with IN (1, 2, 3) (which is in use for all other non-PG providers) has serious performance issues, since the SQL varies with different parameter values (bad for query plans, prepared command caching etc). The new translation makes use of PostgreSQL arrays to use a single SQL for all queries, significantly improving performance.
Unfortunately, arrays are a PostgreSQL-specific feature, and so EF Core doesn't know how to log them. I've opened dotnet/efcore#24595 to track this.
Hello, coming from a previous version of npgsql EF Core (2.2), I noticed the following change regarding executed query logging.
Given the following code:
With the previous version I was getting the following log, where the
ids
values were not parameterized, but they were clearly visible:Now with npgsql EF Core 5.0 I'm getting this log:
The generated SQL is fine, even better because
ids
are now parameterized, but their value is not visible anymore, making harder to run the query manually for debugging purposes.ids
array in the "Parameters" section of the log?Thank you!
The text was updated successfully, but these errors were encountered: