我有一個SQL Server 2008 R2機器與表2列:「警告:鋼柱沒有統計」在空間索引
- 一個用於ID(主鍵集羣)
- 一個用於地理數據
我已經創建了第二個空間索引,但是當我想查詢「最近的鄰居」時,我得到了「沒有統計的列」警告。
我的代碼是這樣的:
CREATE TABLE Links
(Id BIGINT NOT NULL,
Link GEOGRAPHY NULL,
CONSTRAINT PK_Links PRIMARY KEY CLUSTERED(Id)
);
GO
CREATE SPATIAL INDEX LinksSpatialIndex ON Links(Link);
GO
--Fill table
GO
DECLARE @Link GEOGRAPHY= 0xE610000001048100000026AEDEFA0477404082359AE6773458C05D222F7B05774040CCC42136783458C05016C3F405774040EE724C89783458C0CD8E4F670677404057F5E6DF783458C074E68DD206774040D5E2BB39793458C03AF93B360777404082D49396793458C0434D1C9207774040ED8735F6793458C0C038F6E507774040710266587A3458C0EE0496310877404093B5E8BC7A3458C0EC0DCD740877404058A47F237B3458C08CDF71AF087740408289EB8B7B3458C0E04E60E10877404096FEEBF57B3458C08790790A0977404096A33F617C3458C0AC4BA42A097740405047A4CD7C3458C0A5A9CCD73A7D3458C03962E44F0977404086A594A87D3458C064C4E25409774040FC5899167E3458C0B9BBC450097740406550A1847E3458C049D28C43097740408FAF68F27E3458C00E2F432D0977404020C2AB5F7F3458C0E690F50D09774040572527CC7F3458C01A46B7E50877404099F19737803458C07420A1B408774040BBE3BBA1803458C0F165D17A08774040D985510A813458C016BE6B3808774040BC571871813458C0ED1B99ED077740409CF6D0D5813458C0CFA4879A077740403F443D38823458C0E0936A3F07774040418D2098823458C0801A7ADC0677404089AE3FF5823458C09E3DF37106774040C139614F833458C01BB0170006774040C2984DA6833458C03FAA2D8705774040DD2FCFF9833458C068BE7F0705774040E67EB249843458C01AAB5C8104774040FC40C695843458C0582A17F503774040EC8ADBDD843458C0B5BE0563037740401EE8C521853458C0E97D82CB0277404003765B61853458C04AD9EA2E02774040E2FD749C853458C025649F8D01774040130DEED2853458C0369803E8007740406D0BA504863458C044987D3E0077404007507B31863458C02BF17591FF7640401A345559863458C05D5957E1FE76404012241A7C863458C0156F8E2EFE764040B5AEB499863458C055758979FD764040589212B2863458C0EC0FB8C2FC76404027C824C5863458C093FE8A0AFC764040658DDFD2863458C06CD77351FB764040AD6A3ADB863458C0F1C0E497FA7640402B3930DE863458C08D2B50DEF9764040C625BFDB863458C00A8B2825F976404041B2E8D3863458C0FB0FE06CF876404050B4B1C6863458C04A61E8B5F7764040945222B4863458C02D56B200F77640409DFF459C863458C081B0AD4DF6764040CF722B7F863458C0E8D7489DF57640405C9FE45C863458C0A895F0EFF476404024A98635863458C09FD10F46F4764040B1D72909863458C052500FA0F37640403D87E9D7853458C0477255FEF2764040D417E4A1853458C0EEF44561F276404094DA3A67853458C01AB541C9F17640401FFD1128853458C04473A636F1764040517390E4843458C0B899CEA9F076404038DFDF9C843458C0D5041123F076404060772C51843458C03CCDC0A2EF7640406EEBA401843458C05A152D29EF764040CA477AAE833458C0CAD7A0B6EE764040ECD6DF57833458C05EB9624BEE764040DC010BFE823458C08DDDB4E7ED764040452F33A1823458C0AFBDD48BED76404049A19141823458C00D03FB37ED764040305261DF813458C0F8635BECEC7640400ED0DE7A813458C0DA8324A9EC76404062174814813458C07DD67F6EEC764040E86CDCAB803458C07686913CEC7640408636DC41803458C0D85E7813EC764040A2D388D67F3458C039B84DF3EB764040CB74246A7F3458C00A6925DCEB764040E9F2F1FC7E3458C064B90DCEEB76404002A6348F7E3458C0305A0FC9EB764040B53B30217E3458C0D55F2DCDEB7640407B8D28B37D3458C04D4065DAEB764040D17661457D3458C0AED4AEF0EB7640405EAB1ED87C3458C0425EFC0FEC764040378DA36B7C3458C0EE8E3A38EC764040480333007C3458C02C955069EC7640401B500F967B3458C0492B20A3EC764040F7E8792D7B3458C01FAA85E5EC764040844DB3C67A3458C0021F5830ED764040FFDFFA617A3458C00E656983ED7640402DBE8EFF793458C0944186DEED764040049BAB9F793458C0B8837641EE7640403F998C42793458C01027FDABEE764040E5266BE8783458C04B79D81DEF764040E1D97E91783458C0B542C296EF764040B64DFD3D783458C080F16F16F076404075021AEE773458C0C4C7929CF0764040F43C06A2773458C0110CD828F17640406FE8F059773458C06B3CE9BAF176404098790616773458C0AD436C52F27640402BD370D6763458C00EB103EFF27640401B2C579B763458C0C8F14E90F37640405EF7DD64763458C0A78CEA35F476404079CD2633763458C0555F70DFF4764040C3575006763458C06ADD778CF5764040793D76DE753458C0D850963CF6764040B612B1BB753458C0C01B5FEFF67640404649169E753458C06BFB63A4F77640406C23B885753458C04F4C355BF8764040A2A8A572753458C0E34E6213F9764040509CEA64753458C0296D79CCF976404088768F5C753458C0BE800886FA764040D45E9959753458C03F199D3FFB764040FF280A5C753458C0DAC2C4F8FB764040FC53E063753458C0E54C0DB1FC764040CB0A1771753458C052100568FD7640407927A683753458C0B8353B1DFE7640402438829B753458C0F9FA3FD0FE76404006869CB8753458C029F8A480FF7640408F1EE3DA753458C0A063FD2D007740406FDE4002763458C02055DED700774040A07E9D2E763458C0B407DF7D0177404062A3DD5F763458C05A1A991F0277404018EDE295763458C01FCFA8BC02774040010B8CD0763458C0AA48AD5403774040C7CFB40F773458C0F2C548E703774040CD473653773458C019DC20740477404032D1E69A773458C026AEDEFA0477404082359AE6773458C001000000020000000001000000FFFFFFFF0000000003;
SELECT TOP 10 *
FROM Links WITH (INDEX(LinksSpatialIndex))
WHERE Link.STDistance(@Link) IS NOT NULL
ORDER BY Link.STDistance(@Link);
感謝所有
當然(我忘了) –
在我的本地機器上我沒有任何問題 –