4

I have a INSERT query and expected 400k rows to be inserted.

But after execution I have 257k inserted.

My expectation from this query

SELECT count(*) FROM daily_checkups WHERE pig_migration_count = 0

result is 400k

Can somebody explain me, why after insert I have less rows?

insert(<<-SQL.squish)
  INSERT INTO pig_migrations (daily_checkup_id, created_at, updated_at, migration_type, amount)
  (
    SELECT id, created_at, updated_at, 4 as migration_type, 0 as amount
    FROM daily_checkups WHERE pig_migration_count = 0
  )
SQL
9
  • I wrote. Result - 400k Commented Dec 14, 2018 at 8:47
  • How many rows did pig_migrations have before the INSERT? Commented Dec 14, 2018 at 8:51
  • 1
    Is there any triggers on pig_migrations table? Commented Dec 14, 2018 at 8:59
  • 1
    The most likely cause is a trigger that rejects some of the rows. How to check if trigger exists in PostgreSQL? Commented Dec 14, 2018 at 9:27
  • 1
    Did you solved this issue? I would recommend finding one insert statement that does not get inserted. Than check the values against existing table and check the output messages when this insert is run... If nothing is shown and the row is not inserted go to DB logs and check it up... Commented Dec 19, 2018 at 9:54

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.