home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / database / informix / 2687 < prev    next >
Encoding:
Internet Message Format  |  1992-12-14  |  2.6 KB

  1. Path: sparky!uunet!gumby!wupost!emory!emory!not-for-mail
  2. From: jgordon@ssf-sys.DHL.COM (Jim Gordon)
  3. Newsgroups: comp.databases.informix
  4. Subject: Re: Two index query optimization problem
  5. Date: 14 Dec 1992 12:58:07 -0500
  6. Organization: Mailing List Gateway
  7. Lines: 47
  8. Sender: walt@mathcs.emory.edu
  9. Distribution: world
  10. Message-ID: <1gihvfINN3s9@emory.mathcs.emory.edu>
  11. Reply-To: jgordon@ssf-sys.DHL.COM (Jim Gordon)
  12. NNTP-Posting-Host: emory.mathcs.emory.edu
  13. X-Informix-List-ID: <list.1697>
  14.  
  15. > I'm having some problems with Informix over optimizing my query.
  16. > I have a table with > 500000 rows and I can't get Informix to
  17. > use what I deem to be the "correct" index.
  18. >
  19. > There are two indexes on the table:
  20. >
  21. >    index1: unique index on A, B;
  22. >    index2: unique index on C, D, A, B;
  23. >
  24. > The problem I'm having is that I can't run a query with A and B mentioned
  25. > in the WHERE clause that will use index2.  I suspect that the optimizer
  26. > is looking at the query and saying; hey, I got A, I got B, I've got a unique
  27. > index1 on both A and B.  Look no further, I am set dudes and dudettes, and
  28. > I am outta here! (optimizers talk like that you know).
  29. >
  30. Devin,
  31.  
  32. I have had a similar problem in the past in an early version of 4.0
  33. and I found something quite interesting.  Though Informix will tell
  34. you that the new optimiser checks every path for completing the query
  35. in fact it does not check every index.  It always uses the first one
  36. it finds that can help do the query and will ignore later indexes
  37. which are more appropriate.
  38.  
  39. So our solution was to drop both indexes and build them again but in
  40. the opposite order (Index2 followed by Index1).  Now I have not tested
  41. this in 4.1 or 5.0 so I cannot say whether this solution will still
  42. work for you.
  43.  
  44. Alternatively you can change the optimisation level.  It changes for
  45. your backend process until you change it back.  It does not change
  46. for everybody or for ever.  So you can set it to low before the
  47. select statement and set it back to high afterwards.
  48.  
  49. Lastly by splitting the select statement into two or possibly by doing
  50. a sub-query you may also change the choice of index.  This can have
  51. performance impacts, these may not necessarily be negative, there are
  52. times when splitting queries up, using cursors, etc can speed up
  53. response.
  54.  
  55. Cheers - Jim
  56. --------------------------------------------------------------------
  57. Name:     Jim Gordon               Internet: jgordon@ssf-sys.DHL.COM
  58. Company:  DHL Systems Inc          Phone:    (415) 358-5911 (Work)
  59. Address:  1700 S. Amphlett Blvd.             (415) 882-9728 (Home)
  60.           San Mateo, CA 94402      Fax:      (415) 571-6429
  61. --------------------------------------------------------------------
  62.