格網編碼查詢方案在專案運用上的進一步探索

2021-09-08 14:02:10 字數 1250 閱讀 6875

但是,實際專案上,這種優化效果明顯嗎?

select * from tc_geo_address a where a.coordinate_x>504625 and a.coordinate_x<504825 and a.coordinate_y>309858 and a.coordinate_y<310058

select * from tc_geo_address a where a.grid_code=3300000110

其中coordinate_x和coordinate_y以及grid_code上都建立了索引 對比結果:

表大小範圍查詢

單個編碼查詢

2k條0.002s

0.002s

17w條

1.08s

0.84s

為了提高快取命中度,我們以單個格網編碼為主鍵進行快取:

/***

* 通過傳入網格編碼進行搜尋,提供快取功能

listsearchresult=gridcodeutils.gridcodesearch(operconst.mapbounds.get(0),

operconst.mapbounds.get(1), x, y, gridsize, gridsize, radius); if(searchresult==null) //分開利用code查詢是為了充分製造快取命中 for(int i=0;ilisttemaddlist=cachemanager.getaddressbysinglecode(gridhashfield,searchresult.get(i).tostring()); if(temaddlist!=null&&temaddlist.size()>0) }

以上僅僅是根據座標去進行過濾查詢。如果附帶上對查詢結果的進一步條件篩選呢? 這類情況分幾種情況進行討論。

//因為address經常變化,不利於快取,所以用**進行過濾

if(address!="") } }

此時快取機制可能導致資料不是最新的,依然需sql進行查詢。

格網編碼查詢方案在專案運用上的進一步探索

但是,實際專案上,這種優化效果明顯嗎?select from tc geo address a where a.coordinate x 504625 and a.coordinate x 504825 and a.coordinate y 309858 and a.coordinate y 310...

jstl標籤foreach在專案中的運用

在jsp頁面j用的最多的就是用來迴圈遍歷乙個list,話不多說,看 public string updatecontract model model,webrequest request controller層往jsp頁面返回了乙個materiallist的集合,放在了model裡面。解釋一下 it...

相互關聯子查詢在專案中的用法

這3個月一直在做公司的 系統的新功能開發和一些效能改版,經常性的遇見查詢某個地區某個交易品下的最近一天的 在這裡面用到乙個表md historyprices是儲存歷史 記錄。第一種解決方式 用臨時表 1 with temp 2 as 2select areaid goodsid,min priced...