472,378 Members | 1,648 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,378 software developers and data experts.

Filtering An Open Recordset?

Say I've got a RecordSet:

-----------------------------------------------------------
Set myRS = CurrentDB.OpenRecordset(SomeSQL, dbOpenDynaset)
-----------------------------------------------------------

Is there any way to dynamically filter/unfilter/re-filter that RS without
doing any .Opens or .Closes?
--
PeteCresswell
Nov 13 '05 #1
12 8188
Per (Pete Cresswell):
that RS


Access 2003.../JET 4.0.../ADO 2.8...

Been using JET. Maybe something with an ADO RS?

This is in regards to the app bloat problem I've been whining
about in a couple other threads. I'd put some money on it being
associated with tens of thousands of RS Opens/Closes in a batch job.

Come to think of it, maybe I should try feeding my SQL
just the way it is to ADO....
--
PeteCresswell
Nov 13 '05 #2
Per (Pete Cresswell):
Is there any way to dynamically filter/unfilter/re-filter that RS without
doing any .Opens or .Closes?


I think I've got an answer and the answer is "Yes"....

----------------------------------------------------------------------------
With myRS
.Filter = adFilterNone
.Filter = "ReturnDate BETWEEN #01/01/1997# AND #01/01/2003# AND FundID=24835"
End With
----------------------------------------------------------------------------

Sounds like another potential speed increase too....

--
PeteCresswell
Nov 13 '05 #3
Per (Pete Cresswell):
I think I've got an answer and the answer is "Yes"....


Nope.... turns out the .Filter only applies the next time sombody opens a
RecordSet from the .Filtered RS.... so we still have to open a new RS each time
we want a different subset of data.
--
PeteCresswell
Nov 13 '05 #4
"(Pete Cresswell)" <x@y.z.invalid> wrote in
news:7n********************************@4ax.com:
This is in regards to the app bloat problem I've been whining
about in a couple other threads. I'd put some money on it being
associated with tens of thousands of RS Opens/Closes in a batch
job.


Have you changed to avoiding stored querydefs with parameters? If
not, then I don't think you've actually identified the problem.

I've got code that opens tens of thousands of recordsets and the db
does not bloat.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #5
"(Pete Cresswell)" <x@y.z.invalid> wrote in
news:lh********************************@4ax.com:
Per (Pete Cresswell):
I think I've got an answer and the answer is "Yes"....


Nope.... turns out the .Filter only applies the next time sombody
opens a RecordSet from the .Filtered RS.... so we still have to
open a new RS each time we want a different subset of data.


I doubt this could contribute to any large amount of bloat, but are
you running this code in an MDE or an MDB? The direction I'm going
in is that perhaps there's something decompiling the VBA code and it
needs to recompile each time your code loop runs. An MDE would
eliminate prevent that problem from ever happening.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #6
Per David W. Fenton:
Have you changed to avoiding stored querydefs with parameters? If
not, then I don't think you've actually identified the problem.
I cut that routine over to inline SQL about 2:00 this morning and fired up a
volume test.

First thing I noticed was that it runs 25% faster with inline SQL. Tried a few
additional runs and they all supported that number.

I've got code that opens tens of thousands of recordsets and the db
does not bloat.


On my first low-volume tests, I thought I had the bloat licked - there was
some...but I expect that from the first time forms are opened and things like
that.

But on the full-volume test, the 5-meg app was coming right up on a hundred megs
by about 5 a.m.

So I fell back and regrouped. Instead of .Opening/.Closing the RS every time
I called the routine, I opened an RS into the entire Returns table in the
calling routine. Then, as the calling routine loops through another RS,
invoking the problem routine, I pass a pointer to the permanently-opened RS and
the problem routine does .FindFirst/.FindLast to identify the range of records
I'm intersted in and then loops through them.

In low-volume testing, it looked *really* good...like three times faster: .5
seconds per Return as opposed to 1.4 seconds with the inline SQL.

Each return involves many iterations of the problem routine as I calculate
rolling rates of return for 1, 2, 3, 4, 5, 6, 7, 8, 9, and 10 years. So, for
quarterly returns, the first one is four calcs; the second one is eight, the
third one is 12...and so on. Total per return: 220 calculations. There are
also monthlies....

For each calculation, I have to ensure that there is a return present for each
quarter within the period and build a return stream from them.... So that was
..Opening/.Closing a recordset 220 times for each return....
220 & 116,000 = Lotsa .Opens/.Closes.... (25 million+... And that's only for
quarterlies. Monthlies are worse with 12 per year....

When I went to a full-volume test of the always-open-sequential-processing
approach my little bubble burst: 4.1 seconds per return! This seems to
conflict with what I've heard about indexed searching - that if all fields
involved are indexed, the nature of binary searches makes speed relatively
independent of number of records.

But it *does* seem to have stopped the bloat totally/completely albeit at the
cost of bringing the app to it's knees.

For high-volume (i.e. production) we're talking 116,000 records instead of the
low-volume's 1000....and that ain't gonna fly....
(116,000 * 4) /3600 = 132 hours....

I'm going to try to come up with some kind of compromise - maybe loop through
the driver RS one fund at a time and re-create the Return RS with a single
fund's returns - which might put me back at .5 seconds/return or even faster.

If that doesn't work out, maybe I'll just fall back to bloatsville and refresh
the copy of the app every so often.

But it *would* be nice know what's causing the bloat.... I'm also logging
beaucoups error messages using the same kind of DAO IO: for each message, I open
up a recordset, append a record, and then close the RS. And I don't *think*
I'm getting any bloat out of that.

--
PeteCresswell
Nov 13 '05 #7
With myRS
.Filter = "ReturnDate BETWEEN #01/01/1997# AND #01/01/2003# AND
FundID=24835"
Set myRS2 = .OpenRecordset
End With
--
Terry Kreft
MVP Microsoft Access
"(Pete Cresswell)" <x@y.z.invalid> wrote in message
news:2q********************************@4ax.com...
Per (Pete Cresswell):
Is there any way to dynamically filter/unfilter/re-filter that RS without
doing any .Opens or .Closes?
I think I've got an answer and the answer is "Yes"....

--------------------------------------------------------------------------

-- With myRS
.Filter = adFilterNone
.Filter = "ReturnDate BETWEEN #01/01/1997# AND #01/01/2003# AND FundID=24835" End With
-------------------------------------------------------------------------- --
Sounds like another potential speed increase too....

--
PeteCresswell

Nov 13 '05 #8
"(Pete Cresswell)" <x@y.z.invalid> wrote in
news:68********************************@4ax.com:
But it *would* be nice know what's causing the bloat.... I'm also
logging beaucoups error messages using the same kind of DAO IO:
for each message, I open up a recordset, append a record, and then
close the RS. And I don't *think* I'm getting any bloat out of
that.


Where is the error data stored?

Have you tried commenting out the error logging?

And have you tried running this from an MDE rather than an MDB?

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #9
Per David W. Fenton:
And have you tried running this from an MDE rather than an MDB?


That's the second time I've read that. It got lost in all the other stuff.
Maybe it's time to give it a try after the current test gets done.
What would it indicate if the bloat stopped?
--
PeteCresswell
Nov 13 '05 #10
"(Pete Cresswell)" <x@y.z.invalid> wrote in
news:si********************************@4ax.com:
Per David W. Fenton:
And have you tried running this from an MDE rather than an MDB?


That's the second time I've read that. It got lost in all the
other stuff. Maybe it's time to give it a try after the current
test gets done. What would it indicate if the bloat stopped?


That the bloat was being caused by VBA recompilation, not by your
SQL/data retrieval.

I find it *very* unlikely to result in bloat at that order of
magnitude, but VBA compiling always mystifies me as to how many
strange things can go wrong.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #11
Per David W. Fenton:
That the bloat was being caused by VBA recompilation, not by your
SQL/data retrieval.

I find it *very* unlikely to result in bloat at that order of
magnitude, but VBA compiling always mystifies me as to how many
strange things can go wrong.


I tried making the old version (the one that bloats) into a .MDE.

The bloat persists....apparently in 4 or 8k chunks.
--
PeteCresswell
Nov 13 '05 #12
"(Pete Cresswell)" <x@y.z.invalid> wrote in
news:qa********************************@4ax.com:
Per David W. Fenton:
That the bloat was being caused by VBA recompilation, not by your
SQL/data retrieval.

I find it *very* unlikely to result in bloat at that order of
magnitude, but VBA compiling always mystifies me as to how many
strange things can go wrong.


I tried making the old version (the one that bloats) into a .MDE.

The bloat persists....apparently in 4 or 8k chunks.


Have you tried it without the error logging?

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: kgs | last post by:
Problem exists on ms-access, ms-sqlserver using ADO (not in ODBC), visual Basic, C#, and VB.NET. Somethimes when I open second recordset in this same connection that first, it has EOF, but I know,...
4
by: Dalan | last post by:
I presume that using an open recordset method is the preferred method of accomplishing what I'm trying to do. Of course, if there are other options that would work, feel free to share them. I...
2
by: Colleyville Alan | last post by:
I ran into problems in an app in which I received a msg of "cannot lock the table, it is in use by another user". It turns out that I had opened a recordset with a command like set rstmyrecs =...
2
by: Sunil Korah | last post by:
I am having some trouble with opening recordsets. I have used code more or less straight from the access help. But still I am getting some errors. I am unable to work out what exactly I am doing...
0
by: solar | last post by:
I am creating a new recordset in 2 tables, orders and order details.Obviously i have to open the recordset for two tables.Shall i open the recordset for the table order details and when shall i...
2
by: kifaro | last post by:
Hi I am opening recordsets in my asp page with the following command: rs.open mysql,cn,3,3 on occasion it isn't working and I have to do: set rs=cn.execute(mysql) Any clue why?? Regards,...
2
by: Kosmos | last post by:
I am opening the following connections as such although I am only referring to the first connection for this question: Dim con1 As ADODB.Connection Dim con2 As ADODB.Connection Dim recSet1 As...
2
by: banderson | last post by:
Hello Bytes, I am having trouble copying a value from an open record in a recordset into a form. I have a form frmOutreachReferral that is filled in after a Site Visit has been performed and it...
1
by: neerja khattar | last post by:
open a recordset using ado or dao and send the result to a report. I tried using .name property but it doesnt accpet more than 80 characters Report_open_event me.recordsource = rs5.name end ...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
1
by: Johno34 | last post by:
I have this click event on my form. It speaks to a Datasheet Subform Private Sub Command260_Click() Dim r As DAO.Recordset Set r = Form_frmABCD.Form.RecordsetClone r.MoveFirst Do If...
0
by: jack2019x | last post by:
hello, Is there code or static lib for hook swapchain present? I wanna hook dxgi swapchain present for dx11 and dx9.
0
DizelArs
by: DizelArs | last post by:
Hi all) Faced with a problem, element.click() event doesn't work in Safari browser. Tried various tricks like emulating touch event through a function: let clickEvent = new Event('click', {...
0
by: F22F35 | last post by:
I am a newbie to Access (most programming for that matter). I need help in creating an Access database that keeps the history of each user in a database. For example, a user might have lesson 1 sent...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.