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

Bug: Batching results over large queries #31

Closed
Risord opened this issue Nov 29, 2017 · 2 comments
Closed

Bug: Batching results over large queries #31

Risord opened this issue Nov 29, 2017 · 2 comments

Comments

@Risord
Copy link

Risord commented Nov 29, 2017

Batching large queries with TSQL will fail to SqlException: The incoming request has too many parameters. The server supports a maximum of 2100 parameters. Reduce the number of parameters and resend the request.

Bug can be replicated by using hello world model provided by Rezoom.SQL.Provider & Rezoom.SQL.Provider.TSQL. Issue has been replicated to large number of different queries. Sample:

open Rezoom
open Rezoom.SQL
open Rezoom.SQL.Plans
open Rezoom.SQL.Migrations
open Rezoom.Execution
open Rezoom.PlanBuilder

type MyModel = SQLModel<".">

type InsertUser = SQL<"""
    insert into Users(Name, Email) values (@name, @email);
""">

[<EntryPoint>]
let main _ =
    MyModel.Migrate MigrationConfig.Default
    let data = List.init 2000 (fun i -> i.ToString() + "@test.com", None)
    let task =
        plan {
            for (email, name) in batch data do
                do! InsertUser.Command(email, name).Plan()
        }
        |> execute ExecutionConfig.Default
    task.Wait()
    0

This bug was noticed in issue #26 but since it was orginally asked as how-to question I will closed that and opened more clear bug report. As workaround batching and non-batching operations can be manually be used.

Btw library feels pretty stable now in general and we are currently using that for couple of real projects. How about nuget bump after this?

@rspeele
Copy link
Collaborator

rspeele commented Dec 1, 2017

Done & done. Nuget packages are now 0.7.0.

Turns out all that was necessary was to reduce the hardcoded parameter limit for SQL server to be 2098.

Apparently the SqlCommand implementation uses two parameters for itself.

@Risord
Copy link
Author

Risord commented Dec 2, 2017

Seems to work perfectly so far. Thanks!

@Risord Risord closed this as completed Dec 2, 2017
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