📄 increasesqlperformance.htm
字号:
<br>
</span></td></tr></table><table width="100%" border="0" cellpadding="0" cellspacing="0"><tr valign="top"><td width="14"></td><td><span style="font-family:Courier New; font-size:8pt; color:#000000"></span></td></tr></table><span style="font-family:Courier New; font-size:8pt; color:#000000"></span><span style="font-family:Courier New; font-size:4pt; color:#000000">
<br>
</span><span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000"><span style="font-family:Helvetica,Arial; font-size:10pt; color:#010100">the best way to speed it up is to create the following case-sensitive index:
<br>
</span></span><span style="font-family:Helvetica,Arial; font-size:4pt; color:#000000"><span style="font-family:Helvetica,Arial; font-size:4pt; color:#010100">
<br>
<table width="100%" border="0" cellpadding="0" cellspacing="0"><tr valign="top"><td width="14"></td><td><span style="font-family:Helvetica,Arial; font-size:4pt; color:#010100"></span></span></span><span style="font-family:Courier New; font-size:8pt; color:#000000">ABSTable1.AddIndex(<span style="font-family:Courier New; font-size:8pt; color:#000080">'idxCityState'</span></span><span style="font-family:Courier New; font-size:8pt; color:#000000">, <span style="font-family:Courier New; font-size:8pt; color:#000080">'City;State', []</span></span><span style="font-family:Courier New; font-size:8pt; color:#000000">);
<br>
</span></td></tr></table><table width="100%" border="0" cellpadding="0" cellspacing="0"><tr valign="top"><td width="14"></td><td><span style="font-family:Courier New; font-size:8pt; color:#000000"></span></td></tr></table><span style="font-family:Courier New; font-size:8pt; color:#000000"></span><span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000"><span style="font-family:Helvetica,Arial; font-size:10pt; color:#010100">
<br>
If you need to get a better performance for the query:
<br>
</span></span><span style="font-family:Helvetica,Arial; font-size:4pt; color:#000000"><span style="font-family:Helvetica,Arial; font-size:4pt; color:#010100">
<br>
<table width="100%" border="0" cellpadding="0" cellspacing="0"><tr valign="top"><td width="14"></td><td><span style="font-family:Helvetica,Arial; font-size:4pt; color:#010100"></span></span></span><span style="font-family:Courier New; font-size:8pt; color:#000000"><b>SELECT</b> * <b>FROM</b> customer <b>WHERE</b> Upper(City)='KAPAA KAUAI'
<br>
</span></td></tr></table><table width="100%" border="0" cellpadding="0" cellspacing="0"><tr valign="top"><td width="14"></td><td><span style="font-family:Courier New; font-size:8pt; color:#000000"></span></td></tr></table><span style="font-family:Courier New; font-size:8pt; color:#000000"></span><span style="font-family:Courier New; font-size:4pt; color:#000000">
<br>
</span><span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000"><span style="font-family:Helvetica,Arial; font-size:10pt; color:#010100">the best way to speed it up is to create the following case-insensitive index:
<br>
</span></span><span style="font-family:Helvetica,Arial; font-size:4pt; color:#000000"><span style="font-family:Helvetica,Arial; font-size:4pt; color:#010100">
<br>
<table width="100%" border="0" cellpadding="0" cellspacing="0"><tr valign="top"><td width="14"></td><td><span style="font-family:Helvetica,Arial; font-size:4pt; color:#010100"></span></span></span><span style="font-family:Courier New; font-size:8pt; color:#000000">ABSTable1.AddIndex(<span style="font-family:Courier New; font-size:8pt; color:#000080">'idxCity_nocase'</span></span><span style="font-family:Courier New; font-size:8pt; color:#000000">, <span style="font-family:Courier New; font-size:8pt; color:#000080">'City', [ixCaseInsensitive]</span></span><span style="font-family:Courier New; font-size:8pt; color:#000000">);
<br>
</span></td></tr></table><table width="100%" border="0" cellpadding="0" cellspacing="0"><tr valign="top"><td width="14"></td><td><span style="font-family:Courier New; font-size:8pt; color:#000000"></span></td></tr></table><span style="font-family:Courier New; font-size:8pt; color:#000000"></span><span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000"><span style="font-family:Helvetica,Arial; font-size:10pt; color:#010100">
<br>
<br>
</span></span><span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000"><span style="font-family:Helvetica,Arial; font-size:10pt; color:#010100"><b>Available indexes for JOIN conditions</b></span></span><span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000"><span style="font-family:Helvetica,Arial; font-size:10pt; color:#010100">
<br>
<br>
To improve a JOIN query, please check that each field from JOIN conditions has an index.
<br>
For example if you would like to improve the performance of the query:
<br>
</span></span><span style="font-family:Helvetica,Arial; font-size:4pt; color:#000000"><span style="font-family:Helvetica,Arial; font-size:4pt; color:#010100">
<br>
<table width="100%" border="0" cellpadding="0" cellspacing="0"><tr valign="top"><td width="14"></td><td><span style="font-family:Helvetica,Arial; font-size:4pt; color:#010100"></span></span></span><span style="font-family:Courier New; font-size:8pt; color:#000000"><b>SELECT Event_Name,Venue FROM Events e JOIN Venues v ON (e.VenueNo = v.VenueNo)</b>
<br>
</span></td></tr></table><table width="100%" border="0" cellpadding="0" cellspacing="0"><tr valign="top"><td width="14"></td><td><span style="font-family:Courier New; font-size:8pt; color:#000000"></span></td></tr></table><span style="font-family:Courier New; font-size:8pt; color:#000000"></span><span style="font-family:Courier New; font-size:4pt; color:#000000">
<br>
</span><span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000"><span style="font-family:Helvetica,Arial; font-size:10pt; color:#010100">you can create the following indexes:
<br>
</span></span><span style="font-family:Helvetica,Arial; font-size:4pt; color:#000000"><span style="font-family:Helvetica,Arial; font-size:4pt; color:#010100">
<br>
<table width="100%" border="0" cellpadding="0" cellspacing="0"><tr valign="top"><td width="14"></td><td><span style="font-family:Helvetica,Arial; font-size:4pt; color:#010100"></span></span></span><span style="font-family:Courier New; font-size:8pt; color:#000000">VenuesTable.AddIndex(<span style="font-family:Courier New; font-size:8pt; color:#000080">'idxVenueNo'</span></span><span style="font-family:Courier New; font-size:8pt; color:#000000">, <span style="font-family:Courier New; font-size:8pt; color:#000080">'VenueNo', [ixPrimary]</span></span><span style="font-family:Courier New; font-size:8pt; color:#000000">);
<br>
</span></td></tr></table><table width="100%" border="0" cellpadding="0" cellspacing="0"><tr valign="top"><td width="14"></td><td><span style="font-family:Courier New; font-size:8pt; color:#000000">EventsTable.AddIndex(<span style="font-family:Courier New; font-size:8pt; color:#000080">'idxVenueNo'</span></span><span style="font-family:Courier New; font-size:8pt; color:#000000">, <span style="font-family:Courier New; font-size:8pt; color:#000080">'VenueNo', []</span></span><span style="font-family:Courier New; font-size:8pt; color:#000000">);
<br>
</span></td></tr></table><table width="100%" border="0" cellpadding="0" cellspacing="0"><tr valign="top"><td width="14"></td><td><span style="font-family:Courier New; font-size:8pt; color:#000000"></span></td></tr></table><span style="font-family:Courier New; font-size:8pt; color:#000000"></span><span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000"><span style="font-family:Helvetica,Arial; font-size:10pt; color:#010100">
<br>
<br>
</span></span><span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000"><span style="font-family:Helvetica,Arial; font-size:10pt; color:#010100"><b>Rewriting query with OR conditions as a UNION</b></span></span><span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000"><span style="font-family:Helvetica,Arial; font-size:10pt; color:#010100">
<br>
<br>
Absolute DB cannot use indexes to improve performance of a query with OR conditions. You can speedup your
<br>
query
<br>
</span></span><span style="font-family:Helvetica,Arial; font-size:4pt; color:#000000"><span style="font-family:Helvetica,Arial; font-size:4pt; color:#010100">
<br>
<table width="100%" border="0" cellpadding="0" cellspacing="0"><tr valign="top"><td width="14"></td><td><span style="font-family:Helvetica,Arial; font-size:4pt; color:#010100"></span></span></span><span style="font-family:Courier New; font-size:8pt; color:#000000"><b>SELECT * FROM table WHERE (Field1 = 'Value1') OR (Field2 = 'Value2')</b>
<br>
</span></td></tr></table><table width="100%" border="0" cellpadding="0" cellspacing="0"><tr valign="top"><td width="14"></td><td><span style="font-family:Courier New; font-size:8pt; color:#000000"></span></td></tr></table><span style="font-family:Courier New; font-size:8pt; color:#000000"></span><span style="font-family:Courier New; font-size:4pt; color:#000000">
<br>
</span><span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000"><span style="font-family:Helvetica,Arial; font-size:10pt; color:#010100">by creating indexes on each field in the above conditions and by using a UNION operator instead
<br>
of using OR:
<br>
<br>
<table width="100%" border="0" cellpadding="0" cellspacing="0"><tr valign="top"><td width="14"></td><td><span style="font-family:Helvetica,Arial; font-size:10pt; color:#010100"></span></span></span><span style="font-family:Courier New; font-size:8pt; color:#000000"><b>SELECT</b> ... <b>WHERE</b> <b>Field1 = 'Value1'</b>
<br>
</span></td></tr></table><table width="100%" border="0" cellpadding="0" cellspacing="0"><tr valign="top"><td width="14"></td><td><span style="font-family:Courier New; font-size:8pt; color:#000000"><b>UNION</b>
<br>
</span></td></tr></table><table width="100%" border="0" cellpadding="0" cellspacing="0"><tr valign="top"><td width="14"></td><td><span style="font-family:Courier New; font-size:8pt; color:#000000"><b>SELECT</b> ... <b>WHERE</b> <b>Field2 = 'Value2'</b></span><span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000"><span style="font-family:Helvetica,Arial; font-size:10pt; color:#010100">
<br>
</span></span></td></tr></table><table width="100%" border="0" cellpadding="0" cellspacing="0"><tr valign="top"><td width="14"></td><td><span style="font-family:Helvetica,Arial; font-size:10pt; color:#010100"></span></td></tr></table><span style="font-family:Helvetica,Arial; font-size:10pt; color:#010100"></span><span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000"><span style="font-family:Helvetica,Arial; font-size:10pt; color:#010100">
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -