Well, I was premature in stating that this had been resolved. While
encrypting the view copy *did* in fact increase performance, there was a
price to pay. Apparently, when I encrypted the view copy and then
refreshed the original view's link, the original view's link lost its
virtual primary key. (Don't know why, but that's what happened. And I was
able to reproduce this phenomenon.) And, apparently, not having the
virtual primary key made the linked view scroll faster.
To test this I created two links to the same view: one with, and one
without virtual primary key. The one without the virtual primary key
scrolled fast, just like the ADP file; the one with the virtual primary
key was slow.
I ran a trace on these two and on the ADP file when opening and scrolling
the view, and I think I see what's going on here.
When opening the view in the ADP file, profiler shows the following:
SELECT * FROM "vwWebMaintDuplicates"
However, when opening the linked view with the virtual primary key in
place from the MDB file, I get the following:
SELECT "dbo"."vwWebMaintDuplicates"."Index" FROM
"dbo"."vwWebMaintDuplicates"
sp_prepare @P1 output, N'@P1 int,@P2 int,@P3 int,@P4 int,@P5 int,@P6
int,@P7 int,@P8 int,@P9 int,@P10 int', N'SELECT
"Index","TITLE","AUTHILL1","attFirstEdition","attSigned","SignedCond","YRPUB","PRICE","Web","Status","WebStatusPending","ActivateDate","DeactivateDate","WebAddedBatchID","AllowDuplicate","WebAction","WebActionPending","DateModified","DateWebActionApplied","JIT","MImage","HImage","AdCode","OnWeb"
FROM "dbo"."vwWebMaintDuplicates" WHERE "Index" = @P1 OR "Index" = @P2
OR "Index" = @P3 OR "Index" = @P4 OR "Index" = @P5 OR "Index" = @P6 OR
"Index" = @P7 OR "Index" = @P8 OR "Index" = @P9 OR "Index" = @P10', 1
select @P1
sp_execute 4, 1364, 1971, 1978, 2303, 3140, 3480, 3605, 4962, 6747, 6749
SELECT
Index","TITLE","AUTHILL1","attFirstEdition","attSigned","SignedCond","YRPUB","PRICE","Web","Status","WebStatusPending","ActivateDate","DeactivateDate","WebAddedBatchID","AllowDuplicate","WebAction","WebActionPending","DateModified","DateWebActionApplied","JIT","MImage","HImage","AdCode","OnWeb"
FROM "dbo"."vwWebMaintDuplicates" WHERE "Index" = @P1 OR "Index" = @P2
OR "Index" = @P3 OR "Index" = @P4 OR "Index" = @P5 OR "Index" = @P6 OR
"Index" = @P7 OR "Index" = @P8 OR "Index" = @P9 OR "Index" = @P10
"Index" is the name of the primary key field in the main table in the
view, and it's the field that's used as the virtual primary key. The
numbers 1364, 1971, etc., above, are the Index values for the first
records that are returned.
Thus, the MDB linked view with virtual primary key first gets a list of
pk values, then grabs the records ten at a time, specifying the pk values
to get.
This would explain why it's slow in scrolling -- it only gets the records
in sets of ten and has to keep grabbing them.
When I open the linked view in the MDB without the virtual primary key,
profiler shows:
SELECT "Index" ,"TITLE" ,"AUTHILL1" ,"attFirstEdition" ,"attSigned"
,"SignedCond" ,"YRPUB" ,"PRICE" ,"Web" ,"Status" ,"WebStatusPending"
,"ActivateDate" ,"DeactivateDate" ,"WebAddedBatchID" ,"AllowDuplicate"
,"WebAction" ,"WebActionPending" ,"DateModified" ,"DateWebActionApplied"
,"JIT" ,"MImage" ,"HImage" ,"AdCode" ,"OnWeb" FROM
"dbo"."vwWebMaintDuplicates"
This is essentially the same as what's going on in the ADP file, except
that it's specifying a field list, instead of "*".
Thus, without the virtual primary key, the MDB link is fast, like the ADP
file, because it's just getting a set of records. With the virtual
primary key, though, it's getting the list of pk's, and then grabbing
records ten at a time.
This appears to be an inherent property of the way the MDB file/ODBC
driver handles virtual primary keys, and doesn't appear to be anything I
can change. So the question still remains: why is it going slowly when it
used to not, and what can I do about it? Is there anyway to tell it to
get all of it's "sets of ten" at once, when the view is opened, rather
than waiting until the view is scrolled? Are there any other workarounds
or settings that can be tried here?
Anyway, we seem to be back at square one. But at least there's a bit more
knowledge now, and at least it explains the performance increase when the
encryption took place (though not why the virtual pk was lost in the
first place).
Thanks!
Neil
Neil said:
Well, here's the bizarre resolution of this -- fitting for a bizarre
situation.
First, note that the view in question had one main table, two lookup
tables, and a subview. Again, when linked to the MDB file it would
scroll very slowly; but in the ADP file, it was zippidy fast.
I took out the two lookup tables, and reattached the view, and it became
fast in the MDB file as well. However, when I took out just one lookup
table and reattached the view, it was still slow.
Looking for some sort of setting that might help, I stumbled up Encrypt
View. I made a copy of the original view (with both lookup tables) and
encrypted it, and it became zippidy fast in the MDB file!
Great, I figured; now I have to encrypt all my views that are slow and
keep a spare copy for editing. However (and this is the really bizarre
part) that turned out to not be the case.
Though I had tried refreshing the original link before encrypting the
view copy (with no improvement), I tried refreshing the link again after
encrypting the view copy, and, it too was zippidy fast.
In other words, though the original view was unchanged, after I made a
copy of it and encrypted that copy, it became fast again.
I don't understand what happened here, but it clearly must be some sort
of compile/optimization issue which kicked in when I encrypted that copy
of the view.
So if anyone has any idea as to what's going on here, it would be
appreciated. Also, is there any way to force whatever happened here to
happen without having to make a copy of a view, encrypt it, and then
delete it?
Thanks everyone for your assistance.
Neil
I have a situation with an ODBC linked view in an Access 2000 MDB with a
SQL 7 back end. The view is scrolling very slowly. However, if I open
the view in an ADP file, it scrolls quickly.
I needed to use an ODBC link for the view because it needs to be
editable. Otherwise, I would have used a pass-through query.
In previous discussions about using an MDB file vs. an ADP file as a
front end for SQL Server, the impression I got was that both were about
the same, but that the MDB was a more mature technology and less
problematic than the ADP technology. However, the speed difference I'm
noticing with the ADP file in regards to this view is significant and
is very disconcerting re. using an MDB file.
Any thoughts/comments/suggestions would be appreciated. I've reproduced
the view's SQL below for reference.
Thanks,
Neil
SQL for view in question:
SELECT INVTRY.[Index], INVTRY.TITLE, INVTRY.AUTHILL1,
INVTRY.attFirstEdition, INVTRY.attSigned,
ISNULL(INVTRY.attSignedPD, ' ') SignedCond, INVTRY.YRPUB,
INVTRY.PRICE, INVTRY.Web, INVTRY.Status,
INVTRY.WebStatusPending, INVTRY.ActivateDate,
INVTRY.DeactivateDate, INVTRY.WebAddedBatchID,
INVTRY.AllowDuplicate, INVTRY.WebAction,
INVTRY.WebActionPending, INVTRY.DateModified,
INVTRY.DateWebActionApplied, INVTRY.JIT, INVTRY.MImage,
INVTRY.HImage, INVTRY.AdCode,
CASE WHEN INVTRY.WebAddedBatchID IS NOT NULL
THEN - 1 ELSE 0 END AS OnWeb
FROM vwInventory_Dupes INNER JOIN
(WebStatus INNER JOIN
(INVTRY INNER JOIN
tabStatus ON INVTRY.Status = tabStatus.Status) ON
WebStatus.WebStatus = INVTRY.Web) ON
(vwInventory_Dupes.YearPub = INVTRY.YRPUB) AND
(vwInventory_Dupes.SignedCond = ISNULL(INVTRY.attSignedPD,
' ')) AND (vwInventory_Dupes.Signed = INVTRY.attSigned) AND
(vwInventory_Dupes.FirstEd = INVTRY.attFirstEdition) AND
(vwInventory_Dupes.Author = INVTRY.AUTHILL1) AND
(vwInventory_Dupes.TITLE = INVTRY.TITLE)
WHERE (((tabStatus.ForWeb) = 1) AND ((WebStatus.IncludeDupe)
= 1))
SQL for vwInventory_Dupes, used as subquery:
SELECT INVTRY.TITLE, INVTRY.AUTHILL1 Author,
Cast(attFirstEdition AS tinyint) FirstEd,
Cast(attSigned AS tinyint) Signed,
ISNULL(INVTRY.attSignedPD, ' ') SignedCond,
INVTRY.YRPUB YearPub
FROM WebStatus INNER JOIN
(INVTRY INNER JOIN
tabStatus ON INVTRY.Status = tabStatus.Status) ON
WebStatus.WebStatus = INVTRY.Web
WHERE (((tabStatus.ForWeb) = 1) AND ((WebStatus.IncludeDupe)
= 1))
GROUP BY INVTRY.TITLE, INVTRY.AUTHILL1,
Cast(attFirstEdition AS tinyint), Cast(attSigned AS tinyint),
ISNULL(INVTRY.attSignedPD, ' '), INVTRY.YRPUB
HAVING (((COUNT(INVTRY.[INDEX])) > 1))