home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / database / informix / 1847 < prev    next >
Encoding:
Internet Message Format  |  1992-09-01  |  4.0 KB

  1. Path: sparky!uunet!gatech!emory!emory.mathcs.emory.edu
  2. From: widener!obelix.informix.com!johnl@emory.mathcs.emory.edu (Jonathan Leffler)
  3. Newsgroups: comp.databases.informix
  4. Subject: Re:  question on load vs. count(*) counts
  5. Message-ID: <9437@emory.mathcs.emory.edu>
  6. Date: 1 Sep 92 13:18:03 GMT
  7. Sender: walt@mathcs.emory.edu
  8. Reply-To: widener!obelix.informix.com!johnl@emory.mathcs.emory.edu (Jonathan Leffler)
  9. Lines: 73
  10. X-Informix-List-ID: <list.1416>
  11.  
  12. >Date: Mon, 31 Aug 92 16:15:29 EDT
  13. >From: uunet!letterkenn-emh1.army.mil!Root
  14. >Subject: question on load vs. count(*) counts
  15. >X-Informix-List-Id: <list.1412>
  16. >
  17. >A programmer at our site created a new table (unisys 5000, sql 4.0.UE2,
  18. >and SE engine) and then made a flat pipe-separated file with say, 50
  19. >records in it.  Using sql load command, try to load it into empty table.
  20. >
  21. >When the 43rd row had a problem, of course the load halted and a count
  22. >of successful rows loaded was displayed, and the reason (error) encountered.
  23. >
  24. >What we THINK we notice is:
  25. >
  26. >If the error is 846 Number of values in load file not equal to # columns, the
  27. >count displayed is 42, and "select count(*) from table" also yields 42.
  28. >No problem, right? The error in my load file is on line 43, and sure enough,
  29. >there it is. Neat debugging tool.
  30. >
  31. >But, when the errors was either 391 cannot insert a null into column, or
  32. >239 could not iinsert new row - duplicate value in unique index column
  33. >the count displayed is usually 48 (always a multiple of 16).  The error
  34. >occurs within 16 rows before the displayed count. "select count(*) from
  35. >table" displays a count of existing rows which is always less than the
  36. >loader said, but not more than 16 less.  In this example it said 48 rows
  37. >loaded, and the actual select count(*) says 42.  Each time we try this we
  38. >have run delete from table first.
  39. >
  40. >Can anyone explain?  We also have a call into hotline.  Is this a bug in
  41. >4.0 UE2?  Or are we missing something here?  Its easy to work around in an
  42. >empty table, but not in the real world.  Thanks.  This BB is really great
  43. >for quick answers to problems; so much expertise in one place!  Thanks in
  44. >advance.
  45. >
  46. >Ann Barnes
  47. >Letterkenny Army Depot
  48.  
  49. Interesting one.  There is a (relatively) simple explanation for the
  50. problem and I think the circumvention below will work...
  51.  
  52. Error 846 is detected by dbload when it parses an input line.  This means
  53. that it can be precise about where the error is detected, as you observed.
  54.  
  55. Error 391 and 239 are detected by the engine, and the problem is that
  56. dbload uses an INSERT CURSOR to store the data into the database.  This
  57. means that a number of rows are submitted to the database for insertion at
  58. one time, and from your experiments, on your table, you can fit 16 rows in
  59. the buffer.  What happens as far a dbload is concerned is that it reads 16
  60. rows of data, each of which has the correct number of fields, so the values
  61. are PUT into the insert cursor.  When the buffer fills, it has processed
  62. line 48 (for sake of example), but the engine rejects row 33 (as an extreme
  63. case); dbload only knows that the error occurred because the PUT from row
  64. 48 failed with the error and it doesn't know which row actually caused the
  65. trouble.
  66.  
  67. We can argue the toss sometime about whether the design of dbload is
  68. correct or not; the immediate issue is how to get it to work better for
  69. you.
  70.  
  71. I think your best bet is to use the -n option with the value 1; this
  72. should mean that each row is individually committed, giving you accurate
  73. reporting on when errors occur.  This is, however, at the expense of
  74. performance: there are potentially many more transactions which use more
  75. transaction log; and there are more process switches since each row
  76. involves two switches instead of every 16 rows requiring a context switch.
  77. The context switches are more important than the log size for performance,
  78. though the logs can be a nuisance on an OnLine system.
  79.  
  80. Yours,
  81. Jonathan Leffler (johnl@obelix.informix.com) #include <disclaimer.h>
  82.  
  83. PS: dbload syntax picked up from a 4.00 manual -- I don't think it's
  84. changed, but I thought I'd warn you anyway.
  85.