gooderp18绿色标准版
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
6.1KB

  1. <?xml version="1.0" encoding="UTF-8" standalone="no"?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>66.5. GIN Tips and Tricks</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets V1.79.1" /><link rel="prev" href="gin-implementation.html" title="66.4. Implementation" /><link rel="next" href="gin-limit.html" title="66.6. Limitations" /></head><body><div xmlns="http://www.w3.org/TR/xhtml1/transitional" class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">66.5. GIN Tips and Tricks</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="gin-implementation.html" title="66.4. Implementation">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="gin.html" title="Chapter 66. GIN Indexes">Up</a></td><th width="60%" align="center">Chapter 66. GIN Indexes</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 12.4 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="gin-limit.html" title="66.6. Limitations">Next</a></td></tr></table><hr></hr></div><div class="sect1" id="GIN-TIPS"><div class="titlepage"><div><div><h2 class="title" style="clear: both">66.5. GIN Tips and Tricks</h2></div></div></div><div class="variablelist"><dl class="variablelist"><dt><span class="term">Create vs. insert</span></dt><dd><p>
  3. Insertion into a <acronym class="acronym">GIN</acronym> index can be slow
  4. due to the likelihood of many keys being inserted for each item.
  5. So, for bulk insertions into a table it is advisable to drop the GIN
  6. index and recreate it after finishing bulk insertion.
  7. </p><p>
  8. As of <span class="productname">PostgreSQL</span> 8.4, this advice is less
  9. necessary since delayed indexing is used (see <a class="xref" href="gin-implementation.html#GIN-FAST-UPDATE" title="66.4.1. GIN Fast Update Technique">Section 66.4.1</a> for details). But for very large updates
  10. it may still be best to drop and recreate the index.
  11. </p></dd><dt><span class="term"><a class="xref" href="runtime-config-resource.html#GUC-MAINTENANCE-WORK-MEM">maintenance_work_mem</a></span></dt><dd><p>
  12. Build time for a <acronym class="acronym">GIN</acronym> index is very sensitive to
  13. the <code class="varname">maintenance_work_mem</code> setting; it doesn't pay to
  14. skimp on work memory during index creation.
  15. </p></dd><dt><span class="term"><a class="xref" href="runtime-config-client.html#GUC-GIN-PENDING-LIST-LIMIT">gin_pending_list_limit</a></span></dt><dd><p>
  16. During a series of insertions into an existing <acronym class="acronym">GIN</acronym>
  17. index that has <code class="literal">fastupdate</code> enabled, the system will clean up
  18. the pending-entry list whenever the list grows larger than
  19. <code class="varname">gin_pending_list_limit</code>. To avoid fluctuations in observed
  20. response time, it's desirable to have pending-list cleanup occur in the
  21. background (i.e., via autovacuum). Foreground cleanup operations
  22. can be avoided by increasing <code class="varname">gin_pending_list_limit</code>
  23. or making autovacuum more aggressive.
  24. However, enlarging the threshold of the cleanup operation means that
  25. if a foreground cleanup does occur, it will take even longer.
  26. </p><p>
  27. <code class="varname">gin_pending_list_limit</code> can be overridden for individual
  28. GIN indexes by changing storage parameters, and which allows each
  29. GIN index to have its own cleanup threshold.
  30. For example, it's possible to increase the threshold only for the GIN
  31. index which can be updated heavily, and decrease it otherwise.
  32. </p></dd><dt><span class="term"><a class="xref" href="runtime-config-client.html#GUC-GIN-FUZZY-SEARCH-LIMIT">gin_fuzzy_search_limit</a></span></dt><dd><p>
  33. The primary goal of developing <acronym class="acronym">GIN</acronym> indexes was
  34. to create support for highly scalable full-text search in
  35. <span class="productname">PostgreSQL</span>, and there are often situations when
  36. a full-text search returns a very large set of results. Moreover, this
  37. often happens when the query contains very frequent words, so that the
  38. large result set is not even useful. Since reading many
  39. tuples from the disk and sorting them could take a lot of time, this is
  40. unacceptable for production. (Note that the index search itself is very
  41. fast.)
  42. </p><p>
  43. To facilitate controlled execution of such queries,
  44. <acronym class="acronym">GIN</acronym> has a configurable soft upper limit on the
  45. number of rows returned: the
  46. <code class="varname">gin_fuzzy_search_limit</code> configuration parameter.
  47. It is set to 0 (meaning no limit) by default.
  48. If a non-zero limit is set, then the returned set is a subset of
  49. the whole result set, chosen at random.
  50. </p><p>
  51. <span class="quote">“<span class="quote">Soft</span>”</span> means that the actual number of returned results
  52. could differ somewhat from the specified limit, depending on the query
  53. and the quality of the system's random number generator.
  54. </p><p>
  55. From experience, values in the thousands (e.g., 5000 — 20000)
  56. work well.
  57. </p></dd></dl></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="gin-implementation.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="gin.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="gin-limit.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">66.4. Implementation </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 66.6. Limitations</td></tr></table></div></body></html>
上海开阖软件有限公司 沪ICP备12045867号-1