To VFP Gugus: Really OPTIMIZING local views

To VFP Gugus: Really OPTIMIZING local views

Post by Make my da » Sun, 21 Dec 1997 04:00:00



Is there a patch or service pack which allows Foxpro to actually optimize
local views based on a table whose PRIMARY key is a CONCATENATION of two
fields?? For example:

The table has the following indexes:
Index1: FIELD1 + FIELD2 (primary)
Index2: FIELD1 (regular)
Index3: FIELD2 (regular)

set the KeyFieldList property of the view to FIELD1, FIELD2
set the SendUpdates property to .T.
use the view
turn on Foxpro's optimizing feedback feature (using SYS(3054), I believe).
change a row, then move off ot if (or issue a TABLEUPDATE if you want).

You will see Foxpro is making use of the Index2 and Index3, but not Index1.
Why isn't it using index1?  I know you might say that the primary key should
consist of just one field, but for the sake of arguement, let's just say
that it has to consist of two.  What then??

 
 
 

To VFP Gugus: Really OPTIMIZING local views

Post by Jim Boot » Mon, 22 Dec 1997 04:00:00


Hi Make MY day,

What is your name?

SYS(3054) does not tell you about any indexes being used to optimize join
conditions, you need to sue SYS(3054,11) to see that aspect of the plan.

JimB

 
 
 

To VFP Gugus: Really OPTIMIZING local views

Post by Jim Boot » Tue, 23 Dec 1997 04:00:00


Hi Make MY day,

What is your name?

SYS(3054) does not tell you about any indexes being used to optimize join
conditions, you need to sue SYS(3054,11) to see that aspect of the plan.

JimB

 
 
 

To VFP Gugus: Really OPTIMIZING local views

Post by Make my da » Wed, 24 Dec 1997 04:00:00


Thanks.  SYS(3054) aside, was there an answer to the actual question?


>Hi Make MY day,

>What is your name?

>SYS(3054) does not tell you about any indexes being used to optimize join
>conditions, you need to sue SYS(3054,11) to see that aspect of the plan.

>JimB

 
 
 

To VFP Gugus: Really OPTIMIZING local views

Post by Terry Wei » Wed, 24 Dec 1997 04:00:00



: Thanks.  SYS(3054) aside, was there an answer to the actual question?

In order for fox to take advantage of a concatenated key, the expression
must be also be a concatentation of those fields. Rushmore requires the
optimizable expression match the index expression exactly. When you issue
a table
update what essentially happens (and this is a bit of a lie) is that a sql
update gets executed. This update, when it includes two keys will not
issue
a where clause like

Update TableX ;
set field1 = y, field2 = z ;
where field1 + field2 = y+z

instead it will produce  

update TableX ;
set field1 = y, field2 = z ;
where field1 = y and field2 = z

The first is optimizable on the compund index, the second is not.
(Obviously the examples don't make much sense, but illustrate the point).
In terms of pure speed, I'm not sure that statement 1 will be any faster
on a view, X1 AND X2 is as optimizable as X1+X2, if you catch my drift.
HTH.

Terry Weiss

 
 
 

To VFP Gugus: Really OPTIMIZING local views

Post by Make my da » Wed, 24 Dec 1997 04:00:00


Yes, so now (using a local view) how do we force Foxpro to update the table
in the manner you specified? (i.e. Update
TableX set field1 = y, field2 = z where field1 + field2 = y+z)?  The index
is just sitting there waiting to be used in Rushmore, but it seems Foxpro
cannot make the intuitive leap and concatenate field1 and field2 in the
where class of the update (that it is using behind the scenes to update the
table).  Is there a service pack fix that adds this tiny bit of intelligence
to Foxpro's view?



>: Thanks.  SYS(3054) aside, was there an answer to the actual question?

>In order for fox to take advantage of a concatenated key, the expression
>must be also be a concatentation of those fields. Rushmore requires the
>optimizable expression match the index expression exactly. When you issue
>a table
>update what essentially happens (and this is a bit of a lie) is that a sql
>update gets executed. This update, when it includes two keys will not
>issue
>a where clause like

>Update TableX ;
>set field1 = y, field2 = z ;
>where field1 + field2 = y+z

>instead it will produce

>update TableX ;
>set field1 = y, field2 = z ;
>where field1 = y and field2 = z

>The first is optimizable on the compund index, the second is not.
>(Obviously the examples don't make much sense, but illustrate the point).
>In terms of pure speed, I'm not sure that statement 1 will be any faster
>on a view, X1 AND X2 is as optimizable as X1+X2, if you catch my drift.
>HTH.

>Terry Weiss

 
 
 

To VFP Gugus: Really OPTIMIZING local views

Post by Terry Wei » Thu, 25 Dec 1997 04:00:00



: Yes, so now (using a local view) how do we force Foxpro to update the table
: in the manner you specified? (i.e. Update
: TableX set field1 = y, field2 = z where field1 + field2 = y+z)?  The index
: is just sitting there waiting to be used in Rushmore, but it seems Foxpro
: cannot make the intuitive leap and concatenate field1 and field2 in the
: where class of the update (that it is using behind the scenes to update the
: table).  Is there a service pack fix that adds this tiny bit of intelligence
: to Foxpro's view?

In short - no. Once it is broken out as a view, there is no way to flag
the concatenated field as a primary key. Even if you join them in the
view, e.g. select field1, field2, field1+field2, then that compound field
is not updateble and since it has no single corresponding field in the
underlying tables it cannot be taken advantage of. This is not a
limitation of fox, but a consequence of SQL. You would have the same
problem in SQL Server (unless you used an index hint). Also, I would like
to reiterate that there is probably only a minimal performance gain using
the compound index. I know that you requested in your original post that
the schema be left out of it, but a good rule of thumb in fox is to always
use a single surrogate primary key and it would get you out of this
situation rather easily. HTH.

Terry Weiss

 
 
 

To VFP Gugus: Really OPTIMIZING local views

Post by Jim Boot » Thu, 25 Dec 1997 04:00:00


So what is your name?

If you use SYS(3054,11) you may find that the view is using index 1 to
optimize the join condition.  You never showed us the select statement that
comprises the view, therefore we have no idea of how the where clause is
phrased, it must be phrased as WHERE Field1 + Field2 = Value1 + Value2 in
order for Rushmore to recognize the index as being useable for optimization.

JimB


>Thanks.  SYS(3054) aside, was there an answer to the actual question?


>>Hi Make MY day,

>>What is your name?

>>SYS(3054) does not tell you about any indexes being used to optimize join
>>conditions, you need to sue SYS(3054,11) to see that aspect of the plan.

>>JimB

 
 
 

To VFP Gugus: Really OPTIMIZING local views

Post by Jim Boot » Thu, 25 Dec 1997 04:00:00


Make my day,

No service pack will fixed a violation of design.  In the developer's Guide
it clearly says that Rushmore will optimize and operation when it sees an
EXACT match to the key of an index in the comparison operation of the where
clause.  Index 2 and index 3 match the operations but index1 does not match
any clause in the where operations so it doesn't get used.

JimB

 
 
 

To VFP Gugus: Really OPTIMIZING local views

Post by Make my da » Thu, 25 Dec 1997 04:00:00


Actually the problem originally arose out of a need for the code to work
with local Foxpro views as well as REMOTE Oracle views.  The Oracle view
version is extremely fast (due to the fact that in Oracle we set the primary
key to Field1,Field2, and as long as the where clause has those in order,
such as WHERE FIELD1 = y AND FIELD2 = z, it can be very well optimized).
The problem only exists in Foxpro.



>: Yes, so now (using a local view) how do we force Foxpro to update the
table
>: in the manner you specified? (i.e. Update
>: TableX set field1 = y, field2 = z where field1 + field2 = y+z)?  The
index
>: is just sitting there waiting to be used in Rushmore, but it seems Foxpro
>: cannot make the intuitive leap and concatenate field1 and field2 in the
>: where class of the update (that it is using behind the scenes to update
the
>: table).  Is there a service pack fix that adds this tiny bit of
intelligence
>: to Foxpro's view?

>In short - no. Once it is broken out as a view, there is no way to flag
>the concatenated field as a primary key. Even if you join them in the
>view, e.g. select field1, field2, field1+field2, then that compound field
>is not updateble and since it has no single corresponding field in the
>underlying tables it cannot be taken advantage of. This is not a
>limitation of fox, but a consequence of SQL. You would have the same
>problem in SQL Server (unless you used an index hint). Also, I would like
>to reiterate that there is probably only a minimal performance gain using
>the compound index. I know that you requested in your original post that
>the schema be left out of it, but a good rule of thumb in fox is to always
>use a single surrogate primary key and it would get you out of this
>situation rather easily. HTH.

>Terry Weiss

 
 
 

To VFP Gugus: Really OPTIMIZING local views

Post by Jim Boot » Thu, 25 Dec 1997 04:00:00


Make my day,

No service pack will fixed a violation of design.  In the developer's Guide
it clearly says that Rushmore will optimize and operation when it sees an
EXACT match to the key of an index in the comparison operation of the where
clause.  Index 2 and index 3 match the operations but index1 does not match
any clause in the where operations so it doesn't get used.

JimB

 
 
 

To VFP Gugus: Really OPTIMIZING local views

Post by Jim Boot » Thu, 25 Dec 1997 04:00:00


So what is your name?

If you use SYS(3054,11) you may find that the view is using index 1 to
optimize the join condition.  You never showed us the select statement that
comprises the view, therefore we have no idea of how the where clause is
phrased, it must be phrased as WHERE Field1 + Field2 = Value1 + Value2 in
order for Rushmore to recognize the index as being useable for optimization.

JimB


>Thanks.  SYS(3054) aside, was there an answer to the actual question?


>>Hi Make MY day,

>>What is your name?

>>SYS(3054) does not tell you about any indexes being used to optimize join
>>conditions, you need to sue SYS(3054,11) to see that aspect of the plan.

>>JimB

 
 
 

To VFP Gugus: Really OPTIMIZING local views

Post by Make my da » Sat, 27 Dec 1997 04:00:00


Does it matter?  I mean, are you saying that when Foxpro is updating the
table from a view, the WHERE clause of the select statement that makes up
the view is used, while the KEYFIELDLIST property of the view is ignored?  I
thought the KEYFIELDLIST property was the one being used to determine how
the actual table is updated.  It must be in the case of a remote view,
obviously, but are you saying it's ignored in local views?  For my example,
the select statement could have simply been SELECT * FROM TABLE1 (with no
where clause at all).  In that case, wouldn't the KEYFIELDLIST property have
to come into play somehow?


>So what is your name?

>If you use SYS(3054,11) you may find that the view is using index 1 to
>optimize the join condition.  You never showed us the select statement that
>comprises the view, therefore we have no idea of how the where clause is
>phrased, it must be phrased as WHERE Field1 + Field2 = Value1 + Value2 in
>order for Rushmore to recognize the index as being useable for
optimization.

>JimB


>>Thanks.  SYS(3054) aside, was there an answer to the actual question?


>>>Hi Make MY day,

>>>What is your name?

>>>SYS(3054) does not tell you about any indexes being used to optimize join
>>>conditions, you need to sue SYS(3054,11) to see that aspect of the plan.

>>>JimB

 
 
 

To VFP Gugus: Really OPTIMIZING local views

Post by Bill Morri » Sat, 27 Dec 1997 04:00:00



> Is there a patch or service pack which allows Foxpro to actually
> optimize
> local views based on a table whose PRIMARY key is a CONCATENATION of
> two
> fields?? For example:

> The table has the following indexes:
> Index1: FIELD1 + FIELD2 (primary)
> Index2: FIELD1 (regular)
> Index3: FIELD2 (regular)

> set the KeyFieldList property of the view to FIELD1, FIELD2
> set the SendUpdates property to .T.
> use the view
> turn on Foxpro's optimizing feedback feature (using SYS(3054), I
> believe).
> change a row, then move off ot if (or issue a TABLEUPDATE if you
> want).

> You will see Foxpro is making use of the Index2 and Index3, but not
> Index1.
> Why isn't it using index1?  I know you might say that the primary key
> should
> consist of just one field, but for the sake of arguement, let's just
> say
> that it has to consist of two.  What then??

You may not be able to implement this but......
When I have to have a multiple field primary key, I still create a
single field for it.
In the triggers/row valid routines I put "replace PKField with Field1
+Field2, then
I go ahead an create/edit Field1 and Field2 however I need to do it, but
PKFields
gets updated whenever I save.

--
Bill Morris

 
 
 

To VFP Gugus: Really OPTIMIZING local views

Post by Make my da » Sat, 27 Dec 1997 04:00:00


Exactly.  So what we're both saying is that the KEYFIELDLIST property of a
view is useless when we are dealing with a local foxpro table whose primary
key is composed of more than one field.


>Make my day,

>No service pack will fixed a violation of design.  In the developer's Guide
>it clearly says that Rushmore will optimize and operation when it sees an
>EXACT match to the key of an index in the comparison operation of the where
>clause.  Index 2 and index 3 match the operations but index1 does not match
>any clause in the where operations so it doesn't get used.

>JimB

 
 
 

1. Q: Local Views and Requery() VFP 5.0

I need help,

I use local views with 5 records and i would like to requery next 5
records.

This is my click event on my next button
-----------------------------------------------------------
Requery()
IF !EOF()
        skip
endif
if eof()
        skip -1
        STORE .T. TO THIS.Parent.IsLast
endif
STORE BOF() TO THIS.Parent.IsTop
This.Parent.RecDel = Delete()
THIS.Parent.Show()
-------------------------------------------------------------
Thank You
--

----------------------------
     JOCELYN BROUILLARD

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

2. Approach Users Mailing List FAQ

3. VFP 6-Local view not updating table

4. Using Paradox on Networks results in un-synchronization of data??

5. Q: Anatomy of a VFP Local View

6. ODBC Driver Locations

7. VFP 3.0 Local View

8. Moving SQL server to another server

9. VFP 3.0b - A SELECT from a local view

10. optimize: view of views

11. ASA6: Optimize view of a view?????

12. fine tune BCP and optimize Procedures - really confused

13. Ontape being really, really, really SLOW...