gpt4 book ai didi

database - 在 PostgreSQL 数据库表中实现具有 100 多列的高性能搜索的最佳方法是什么?

转载 作者:行者123 更新时间:2023-12-03 02:25:04 25 4
gpt4 key购买 nike

下图是我想要完成的事情。

  • 几个高级实体(表)例如:如图所示:公司、人员等
  • 可能有数百种不同的过滤条件(每一个都是表格中的一列)
  • An example query could be: "Give me all fintech startups based in San Fransisco that started less than a year ago and have raised more than $1 million funding"(with the bold words being examples of filter值)

  • Another example query for a different domain could be: "Show me all vegan restaurants in London where rating > 4.5 and restaurant age > 5 years and average monthly customers > 5000 .

    enter image description here

    我需要知道的是,为了获得 google-esque 类型并获得即时结果体验,实现这一点的最佳、最高效的方法是什么?我将在每个表中有数百万行,每个表中有近百列(总共几十 GB 的原始数据,不包括索引),它们可能起到全文搜索或过滤/排序的作用标准。

    我正在使用 PostgreSQL 并探索过 postgres 全文搜索功能,我也在考虑使用 ElasticSearch。 postgres native 搜索 + 索引列是最好的方法吗? postgres + elasticsearch的组合?完全是别的东西吗?

    最佳答案

    Postgres 是一个关系数据库,适用于规范化涉及多个表的数据和查询,但不擅长搜索和过滤数据。 虽然 elasticsearch 非常适合搜索和过滤

    Elasticsearch 甚至提供了 out of the box filter cache ,这意味着如果您基于某些列过滤数据,而其他一些用户再次使用相同的过滤条件,那么 elastic 将不会再次过滤数据并提供其过滤器缓存中的结果,如引用链接中所述。

    我知道,您的应用程序中的 MongoDB 和 Elastic 用例,Elasticsearch 都不是数据库,它们也不打算取代关系数据库,如果您不能承受任何数据丢失,请始终使用数据库,请参阅 this Elasticsearch discuss link for more info

    底线是,在这种情况下,您应该只在搜索索引中包含将用于搜索和过滤的相关属性,但是如果您要存储事务数据并且买不起数据,您还应该将数据存储在 Postgres 中-损失

    https://www.elastic.co/guide/en/elasticsearch/resiliency/current/index.html 是关于 Elasticsearch 弹性的很好读物,根据您的用例,您是否可以将其用作主存储。

    关于database - 在 PostgreSQL 数据库表中实现具有 100 多列的高性能搜索的最佳方法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61323755/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com