简体   繁体   English

如何最好地开发sql以支持Web应用程序中的搜索功能?

[英]How best to develop the sql to support Search functionality in a web application?

Like many web applications (business) the customer wants a form that will search across each data field. 与许多Web应用程序(业务)一样,客户想要一个将在每个数据字段中搜索的表单。 The form could have 15-20 different fields where the user can select/enter/input to be used in sql (stored procedure). 表单可以有15-20个不同的字段,用户可以在sql(存储过程)中选择/输入/输入。

These are quite typical requests by the user that most every application has to deal with. 这些是用户非常典型的请求,大多数应用程序都必须处理这些请求。

The issue really at hand is how to provide the user with this type of interface/option AND establish fast SQL access. 真正的问题是如何为用户提供这种类型的接口/选项建立快速SQL访问。 The above fields could span 15 different tables and respective sql statements (usually abstracted to a stored procedure) will have as many joins. 上面的字段可以跨越15个不同的表,并且相应的sql语句(通常抽象为存储过程)将具有尽可能多的连接。 The data always has to be brought back to a grid type view as well as some report format (often excel). 数据总是必须返回到网格类型视图以及一些报告格式(通常是excel)。

I/we are finding these sql statements are slow and hard to optimize as the user can enter 1 or 15 different search criteria. 我/我们发现这些sql语句很慢并且难以优化,因为用户可以输入1或15个不同的搜索条件。

How should this be done? 该怎么做? Looking for suggestions/ideas as to how existing large applications deal with these requirements. 寻找有关现有大型应用程序如何处理这些要求的建议/想法。
Does it really come down to trying to optimize the sql within the stored procedure? 是否真的归结为尝试优化存储过程中的sql?

thx 谢谢

No, you need to employ a real search engine technology to make fulltext search have good performance. 不,您需要采用真正的搜索引擎技术来使全文搜索具有良好的性能。 No SQL predicate (eg LIKE '%pattern%' ) is going to be scalable. 没有SQL谓词(例如LIKE '%pattern%' )将是可扩展的。

You don't identify which brand of RDBMS you're using, but every major brand of RDBMS has their own fulltext search capability: 您没有确定您使用的是哪个品牌的RDBMS,但RDBMS的每个主要品牌都有自己的全文搜索功能:

There are also third-party solutions for indexing text, such as: 还有用于索引文本的第三方解决方案,例如:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM