Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. Step 1:
  2.  
  3. CREATE TABLE a (
  4. a_id int PRIMARY KEY
  5. );
  6.  
  7. Step 2:
  8.  
  9. CREATE TABLE b (
  10. b_id int,
  11. a_id int REFERENCES a(a_id)
  12. ON UPDATE CASCADE
  13. ON DELETE CASCADE
  14. );
  15.  
  16. Step 3:
  17.  
  18. INSERT INTO a
  19. SELECT x
  20. FROM generate_series(1, 5000000) AS x;
  21.  
  22. Step 4:
  23.  
  24. INSERT INTO b
  25. SELECT x, x
  26. FROM generate_series(1, 5000000) AS x;
  27.  
  28. Step 5:
  29.  
  30. explain analyze DELETE FROM a WHERE a_id = 10;
  31.  
  32. Step 6:
  33.  
  34. CREATE INDEX idx_b ON b (a_id);
  35.  
  36. Step 7:
  37.  
  38. explain analyze DELETE FROM a WHERE a_id = 11;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement