-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
for columns with uppercase letters, generated indexes don't hit #5128
Comments
Yeah I added a case sensitive flag so you can use the adapter without all the postgresql_connection: {
adapter: 'sails-postgresql',
url: process.env.DATABASE_URL,
wlNext: {
caseSensitive: true
}
} |
Yeah... unfortunately when you have ~40 tables that have existing indexes on the lowercase column names, switching to case sensitivity isn't trivial. Would be nice to be able to add case sensitivity table-by-table, I added #2804 to discuss further. |
Table-by-table would be interesting but harder to configure. Whats the issue with case-sensitivity? You have a lowercase column, say username, and want to query using the index right?
which translates to the following waterline query: Account.find({
username: 'Foo'.toLowerCase()
}).exec(....) |
Or what does the sql query need to look like? |
I guess either the queries and the indexes need to use lower() or neither -kevin On Apr 1, 2015, at 18:30, Cody Stoltman notifications@github.com wrote: Or what does the sql query need to look like? — |
Yeah in order to hit indexes on strings you have to add that flag above (which is why I added it actually). That flag bypasses the normal behavior of WL which is to wrap everything in a case-insensitve wrapper. But then now this makes all your queries case sensitive. Although all postgresql queries are case sensitive normally. In order to keep waterline from branching api's we made it do case insensitive queries. MySql was the first adapter and unfortunately defined the api for the others so here we are. I guess we could wrap a layer around the query builder so that if a field has an index make it case-sensitive but that just seems like a headache and would be confusing for people as to why certain fields are case sensitive and others are not. Maybe the best solution is to add a flag on the model definition so a single attribute is case-sensitive and it's explicitly defined. God knows how we would implement that in MySql though. |
Postgres objects are case insensitive. Are you sure this index isn't working? As far as columns are concerned in pg, |
Yes, positive. If the column is named "userId" (capital I) and you type select * from users where userId='usr123' The default behavior of Postgres is to search for a column named "userid" It's pretty easy to double check this, add an index to a table on an
and verify that the result says Seq Scan. Then add an index on You can verify the query that Sails is generating by enabling query logging Thank you for not asking "why are you using capital letter column names", -kevin On Apr 2, 2015, at 03:00, Travis Webb notifications@github.com wrote: However, the queries generated from WL/sails-postgresql call Postgres objects are case insensitive. Are you sure this index isn't — |
(The confusion may come from, you can create a column and spell it |
Ah so the issue is only on column name? Will it hit the index if we do the following query?
If it's just an issue with column name we can probably remove that completely. |
Hmm, it's possible.. you're suggesting moving the LOWER() to the query parameter instead of the column name? That should hit the index. I'm not sure if it would have the same behavior, at a minimum it would be good to have tests around it. |
I'm not sure if this is related, but anything that uses waterline-sequel will miss any string index unless you're using
in your connection definition. This is the current expected behavior as illustrated by: By calling calling the |
Thanks for posting, @kevinburkeshyp. I'm a repo bot-- nice to meet you! It has been 30 days since there have been any updates or new comments on this page. If this issue has been resolved, feel free to disregard the rest of this message. On the other hand, if you are still waiting on a patch, please:
Thanks so much for your help! |
Not sure if this is fixed in the latest version or what. The following attributes in a Sails model
generates the following index:
However, the queries generated from WL/sails-postgresql call LOWER("tablename"."userId"), so they completely miss the index for queries which find by ID:
I know there's some work going on to add case sensitivity, but it's not on yet, & this could trip people up if they are using the automagicalmigrate setting.
The text was updated successfully, but these errors were encountered: