Eloquent Typecasting to nvarchar(4000)

Posted 8 months ago by timroush

In our DB monitoring, we typically see Eloquent casting string variables to nvarchar(4000) when building its queries. This can cause it to bypass an index on a varchar column since it has to do the implicit type cast.

Has anyone run into this before, and is there a way to default it to either not try to cast strings, or to define what they should be cast to, so that we can make use of our indexing?

Please sign in or create an account to participate in this conversation.

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up

Channels

Reply to

Use Markdown with GitHub-flavored code blocks.