Results 1 to 2 of 2
  1. #1
    Join Date
    May 2003
    Posts
    5

    Queries Question

    With Relational View, it is more easy to specify queries? Also, it is more efficient to execute the queries?

  2. #2
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171

    Re: Queries Question

    Originally posted by convo
    With Relational View, it is more easy to specify queries? Also, it is more efficient to execute the queries?
    No, under the covers the view gets expanded into a query against the base tables, and will be exactly as efficient as the expanded query would be if issued directly. Of course, if the view used is inappropriate for the query, it may be slower than the query the user really wanted. For example, consider the view:

    CREATE VIEW dept_info AS
    SELECT dept.deptno, dept.deptname, SUM(emp.salary) AS dept_salary
    FROM dept, emp
    WHERE dept.deptno = emp.deptno
    GROUP BY dept.deptno, dept.deptname;

    If the user queries:
    SELECT deptno, deptname, dept_salary
    FROM dept_info;

    that will be perfectly efficient. However, if the user queries just:
    SELECT deptno, deptname
    FROM dept_info;

    then that may be much less efficient than:
    SELECT deptno, deptname
    FROM dept;

    (unless the optimizer is clever enough to realise that the join to emp and GROUP BY are unnecessary!)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •