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

INSERTs with executeMany should only emit one INSERT query #82

Open
jdreaver opened this issue Jan 28, 2020 · 1 comment
Open

INSERTs with executeMany should only emit one INSERT query #82

jdreaver opened this issue Jan 28, 2020 · 1 comment

Comments

@jdreaver
Copy link

Hello!

I noticed today that when I INSERT with executeMany, there are multiple insert queries instead of a single query. SQLite supports lists of values to insert mutliple rows in a single query. For example:

> create table test (a integer, b integer);
> insert into test (a, b) values (1, 2), (3, 4);
> select * from test;
a           b         
----------  ----------
1           2         
3           4 

executeMany does this:

> insert into test (a, b) values (1, 2);
> insert into test (a, b) values (3, 4);

which of course is less efficient than doing it all in one query.

postgresql-simple seems to know about this, so I was surprised to see sqlite-simple emit multiple insert queries.

@sigrlami sigrlami self-assigned this Jan 28, 2020
@sigrlami
Copy link
Collaborator

Hi, yes insertMany is a for loop

executeMany :: ToRow q => Connection -> Query -> [q] -> IO ()
of simple queries. This will probably improved over next couple releases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants