question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to Suppress SELECT query after INSERT?

See original GitHub issue

Issue type:

[x] question [ ] bug report [ ] feature request [ ] documentation issue

Database system/driver:

[ ] cordova [ ] mongodb [x] mssql [ ] mysql / mariadb [ ] oracle [ ] postgres [ ] cockroachdb [ ] sqlite [ ] sqljs [ ] react-native [ ] expo

TypeORM version:

[ ] latest [ ] @next [x] 0.2.9 (or put your version here)

I am executing the following line of code in a transaction using entity manager

await entityManager.insert(
                      CriteriaClause,
                      {
                        customerId: clause.customerId,
                        criteriaStatementId: clause.criteriaStatementId,
                        criteriaPhraseNum: clause.criteriaPhraseNum,
                        fieldName: clause.fieldName,
                        lowValue: clause.lowValue,
                        highValue: clause.highValue,
                        criteriaOperatorId: clause.criteriaOperatorId,
                        criteriaTableId: clause.criteriaTableId,
                        modifiedBy: clause.modifiedBy
                      },
                      { reload: false }
                    );

When this code executes, it’s extremely slow because of the select query after the insert. My understanding is that setting the reload option to false should suppress the query. If this is not the way, how would I do that?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:9
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

30reactions
asechercommented, Jan 19, 2020

@nrcmkoh You can use updateEntity(false) with an insert query builder like this:

entityManager
  .createQueryBuilder()
  .insert()
  .into("user")
  .values(users)
  .updateEntity(false)
  .execute();
3reactions
nrcmkohcommented, Dec 17, 2019

Any plans to implement fix resolve this? I’m hitting up against this again, and I don’t want to have to write raw SQL every time I need fast inserts. I feel like the reload negates the performance benefits of using insert, especially since it’s creating a select statement for each record.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Suppress result from insert trigger - sql - Stack Overflow
After a quick review of your query my first thought is that you're getting results due to the select * from #inserted.
Read more >
How to suppress MySQL stored procedure output?
To suppress MySQL stored procedure output, you can use variable. Let us first create a table. mysql> create table person_information ...
Read more >
Slow select after bulk insert-remove - Ask TOM
3. Remove all rows from table t_reg_account using DELETE statement. 4. Execute select from 2. Now the same query consumes several hundreds of ......
Read more >
INSERT INTO SELECT statement overview and examples
This article covers the INSERT INTO SELECT statement along with its syntax, examples and use cases.
Read more >
How to Use Subqueries in INSERT, UPDATE, and DELETE ...
To prevent this, we add a subquery to the INSERT statement to see if an invoice with the same order_id already exists. The...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found