Re: Views

From: Jonathan Lewis <Jonathan_at_jlcomp.demon.co.uk>
Date: Sat, 25 Mar 1995 14:03:45 +0000
Message-ID: <796140225snz_at_jlcomp.demon.co.uk>


In article <3kvcrn$sjv_at_newsbf02.news.aol.com>

           vincen5158_at_aol.com "Vincen5158" writes:

: I'm an advocate for the use of views, but this is the first time I've
: heard of a view running faster than a table query.

Wandering off the topic here, but there are times when you can guarantee that a view will be faster than the underlying query, (although what I'm about to say doesn't apply in this case).

consider a select like:

    select

	complicated_expression_for_A,
	complicated_expression_for_B,
	even_more_complicated_expression_for_the_difference
     from the_table;

then create a view:

   create the_view as
    select

	complicated_expression_for_A    A,
	complicated_expression_for_B	B
     from the_table;

The statement:

    select A, B, A-B
      from the_view;

will be faster (basically less CPU) than the table select.

The benefit is usually relatively small: but for large numbers of rows returned on an efficient system, it can quite surprising (especially if A and B appear multiple times, and in the WHERE clause).

--
Jonathan Lewis
Received on Sat Mar 25 1995 - 15:03:45 CET

Original text of this message