home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / database / 6160 < prev    next >
Encoding:
Internet Message Format  |  1992-08-17  |  5.3 KB

  1. Xref: sparky comp.databases:6160 comp.databases.theory:364
  2. Path: sparky!uunet!oracle!unrepliable!bounce
  3. Newsgroups: comp.databases,comp.databases.theory
  4. From: mfriedma@uucp (Michael Friedman)
  5. Subject: Re: Relational Queues
  6. Message-ID: <1992Aug16.062239.24049@oracle.us.oracle.com>
  7. Sender: usenet@oracle.us.oracle.com (Oracle News Poster)
  8. Nntp-Posting-Host: appseq
  9. Organization: Oracle Corporation
  10. References: <1992Aug12.113531.4654@mp.cs.niu.edu> <1992Aug13.195729.19884@oracle.us.oracle.com> <1992Aug14.202406.17593@mp.cs.niu.edu>
  11. Date: Sun, 16 Aug 1992 06:22:39 GMT
  12. X-Disclaimer: This message was written by an unauthenticated user
  13.               at Oracle Corporation.  The opinions expressed are those
  14.               of the user and not necessarily those of Oracle.
  15. Lines: 95
  16.  
  17. In article <1992Aug14.202406.17593@mp.cs.niu.edu> higgins@mp.cs.niu.edu (Greg Higgins) writes:
  18. >In article <1992Aug13.195729.19884@oracle.us.oracle.com> mfriedma@uucp (Michael Friedman) writes:
  19. >>In article <1992Aug12.113531.4654@mp.cs.niu.edu> higgins@mp.cs.niu.edu (Greg Higgins) writes:
  20. >>>In article <1992Aug7.200632.22867@oracle.us.oracle.com> mfriedma@uucp (Michael Friedman) writes:
  21. >>>>In article <BsKzHw.9sy@world.std.com> edwards@world.std.com (Jonathan Edwards) writes:
  22.  
  23. >>>>>How do you implement a standard FIFO queue in the relational model?
  24.  
  25. >>>>>Here's the rules: multiple producers, multiple consumers. No possibility of
  26. >>>>>two consumers getting the same record. Ability for consumer to wait if the
  27. >>>>>queue is empty (no polling allowed!). Strict FIFO, but to make it a little
  28. >>>>>easier, I only ask that a record enqueued by one transaction come before all
  29. >>>>>records enqueued by other transactions that START after the first one COMMITS.
  30. >>
  31. >>>>>I believe that this can only be done by setting up a central server program,
  32. >>>>>called from the producers and consumers (perhaps via RPC), which serializes
  33. >>>>>access to the relation representing the queue. If this is true, doesn't anyone
  34. >>>>>else find this a rather glaring weakness?
  35.  
  36. >>>>The SQL standard supports sequences.  Just create an increasing
  37. >>>>sequence and use it to number each item you add to the table.  Then
  38. >>>>when you pop items off, just select where SEQ_NUMBER = MAX(select
  39. >>>>seq_number from table).  
  40.  
  41. >>>Hardly. This implements a LIFO queue.
  42.  
  43. >>Sorry.  Momentary attack of braindeadness.  Just replace MAX with MIN.
  44.  
  45. >The guy next to me is working on MIN; I want MIN + 1, but then so 
  46. >do the other 20 people in the room.
  47.  
  48. Good point.  Adding simultaneous users makes it tougher. 
  49.  
  50. Well, tag it.
  51.  
  52. update TABLE
  53.     set IN_USE = 'Y'
  54.     set PROCESS_USER = _MY_PROCESS_ID
  55.     WHERE SEQ_NUMBER = MAX(select seq_number from table where
  56.                 IN_USE = 'N');
  57.  
  58.  
  59. >>>>In general, however, this wouldn't even be a weakness if we didn't
  60. >>>>have a solution.
  61.  
  62. >>>>SQL is intended to solve real world problems, not comp sci questions.
  63. >>>>If you don't have the information in your database to know which item
  64. >>>>in your list should be dealt with next then either you didn't design
  65. >>>>your database right or it doesn't matter which comes next.
  66.  
  67. >>>Wanting a FIFO queue is not just a comp sci problem. It is a real world
  68. >>>problem, and one which application developers need to deal with frequently.
  69.  
  70. >>>Consider a help desk situation where you have a first line tech support
  71. >>>screening calls, entering them into the database, and then putting the
  72. >>>folks who need more help on hold for second level support. 
  73.  
  74. >>>You want second level support to pick up those call in the correct order.
  75.  
  76. >>>Note that the correct order may not be the serial number, since presumably
  77. >>>that would be the initial entry into the database by the first line support.
  78.  
  79. >>So what is the correct order?  Probably it's the order in which they
  80. >>were put on hold for second level support.  So how would I handle that
  81. >>if I didn't have sequences?  Hmm.  Well, would a timestamp do?  Yup.
  82. >>And if you don't have a time stamp you didn't design the database
  83. >>right.
  84.  
  85. >>SQL has its limitations (explosion of parts, for one) but this isn't
  86. >>one of them.
  87.  
  88. >"comp sci questions" is vendorese for "Shut up, buy my product, and we'll
  89. >figure out later if it can actually do the job." I've heard it a lot,
  90. >especially from representatives of a large, well known database
  91. >vendor. If put to me when I'm in the right mood, as I apparently was
  92. >the other day, it gets my dander up. 
  93.  
  94. Well, considering that SQL is pretty much standard between Oracle and
  95. all of our significant competitors I'm not going to run arround
  96. making a fuss about how SQL can do the job.  It's an industry
  97. standard and we don't need to defend it any more.
  98.  
  99. As for "comp sci questions" versus real word questions, I really do
  100. believe there is a difference.  I'll admit that you've given a pretty
  101. good example of a need for a FIFO queue, but in the vast majority of
  102. applications you really don't need one.  Or a circular buffer.  Or a
  103. LIFO queue.  Sometimes you need things that behave a little bit like
  104. them - like making your inventory application do LIFO or FIFO
  105. accounting - but you're unlikely to implement it as a queue even if
  106. you're pretending that the goods sold are the (last or first) to be
  107. placed in your warehouse.
  108.  
  109. -- 
  110. -------------------------------------------------------------------------------
  111. I am not an official Oracle spokesman.  I speak for myself and no one else.
  112.