gpt4 book ai didi

java - 改进搜索功能

转载 作者:行者123 更新时间:2023-11-30 06:25:23 25 4
gpt4 key购买 nike

如何改进搜索功能?我写了一些代码来搜索一些东西。搜索花费了太多时间。以及这里的代码片段,

我正在使用这种方法从数据库中提取数据。,

   OracleConnection connection = null;
OraclePreparedStatement ptmst = null;
OracleResultSet rs = null;
OracleCallableStatement cstmt = null;
StringBuffer strBfr = new StringBuffer();
ArrayList myList = new ArrayList();
try
{
connection = (OracleConnection) TransactionScope.getConnection();
strBfr.append("select distinct .......... ");
ptmst = (OraclePreparedStatement)connection.prepareStatement(strBfr.toString());
rs = (OracleResultSet)ptmst.executeQuery();
while (rs.next())
{
HashMap hashItems = new HashMap();
hashItems.put("first",rs.getString(1));
hashItems.put("second",rs.getString(2));
myList.add(hashItems);
}

}
catch (Exception e) {
}
finally {

try {
if (ptmst != null) {
ptmst.close();
}
} catch (Exception e) {
}

try {
if (connection != null) {
TransactionScope.releaseConnection(connection);
}
} catch (Exception e) {
}

}
return myList;

在我的jsp中:

 ArrayList getValues = new ArrayList();     
getValues = //calling Method here.
for(int i=0; i < getValues.size();i++)
{
HashMap quoteSrch=(HashMap)allPOV.get(i);
first = (String)quoteSrch.get("first");
second = (String)quoteSrch.get("second");
}

查询:

SELECT DISTINCT(mtl.segment1),
mtl.description ,
mtl.inventory_item_id ,
mtl.attribute16
FROM mtl_system_items_b mtl,
mtl_system_items_tl k
WHERE 1 =1
AND mtl.organization_id = ?
AND k.inventory_item_id = mtl.inventory_item_id
AND NVL(orderable_on_web_flag,'N')= 'Y'
AND NVL(web_status,'UNPUBLISHED') = 'PUBLISHED'
AND mtl.SEGMENT1 LIKE ? --Here is the search term

最佳答案

确保 organization_id 、 inventory_item_id 尤其是 SEGMENT1 已在您的表中编入索引。

您的查询非常标准,如果这不起作用,那么您的数据库服务器似乎响应缓慢,这可能是由于空间不足、内存不足、磁盘/读取速度慢等多种原因造成的。

然后您可以要求您的 DBA/服务器管理员进行检查。

关于java - 改进搜索功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15607476/

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