Does MySQL have an equivalent of SQL Server "indexed views"? - sql

Does MySQL have an equalavent to SQL Servers "indexed view" functionality?
Is a view faster than a simple query?
What I'm specifically looking for is a way for MySQL to create a "view" that will return results faster than simply performing the underline view's query/sql.

An Indexed View is SQL Server terminology for a materialized view, which MySQL does not support.
You can either:
re-create a temporary table, populated with the desired columns, at a given interval
use an actual table, populated and indexed though again - there'd have to be a process to keep the data and indexes current

Related

Moving Data from SQL Server to Excel, Views or Query?

I have an Excel spreadsheet that pulls data from a view (that's pulling from another view) in SQL Server, this was created by someone other than myself. Due to recent changes in how we are storing data in SQL Server, the views no longer actively reflect the data needed.
The current Excel spreadsheet use a command to simply pull the rows from the view, would it make more sense to simply use a query to gather the data from the necessary tables? Is there any advantages to using the views over a regular query?
There is no security being enforced in regards to the view as well, the connection is using an admin user.
When we talk about regular views, the only advantage over query is that I see a shorter expression, i.e. 'select * from view' will be easier to type and edit in MS Query than 'select * from ... join ... join ... where ...' etc. If we are talking about indexed views, then they can greatly improve performance

how to convert materialized view into normal view

I am using Oracle 11g EE and created one Materialized view for a complex query.
But as customer is using Standard edition and it doesn't support Materialized view.
So I need to convert materialized view into a normal view.
Along with this conversion I also need to make sure performance of a query.
When I treid to execute a query for the view independently, it takes around 20 mins which is too much time.
All my tables are indexed.
Any sort of help would be appreciated !!
I don't currently have access to an oracle database to test this, but if you get the DDL of the mview, and remove the word materialized along with the mview related options:
select dbms_metadata.get_ddl('MATERIALIZED_VIEW', 'MVIEW_NAME') from dual;
You should be able to create a normal view from the resulting modified statement.
As for performance, make sure you are indexing the right things, and using the right type of indexes. Make sure statistics are up to date, and finally run explain plan on the view query. The topic of interpreting and optimizing execution plans is deep - start here:
https://docs.oracle.com/cd/B10501_01/server.920/a96533/ex_plan.htm

Index view and execution plan

I created an indexed view that joined a number of tables to get better performance, but when I use the indexed view, the performance is not better than before. When I survey the execution plan, I don't see any change between the view and the indexed view on these joined tables.
If you are not using sql server enterprise edition (see feature Automatic use of indexed views by query optimizer), sql server query optimizer is not taking in account indexed views..
In other versions you can make sql server use it- With (NoExpand):
Select col1, col2, col3
From dbo.vw_MyView With (NoExpand)

To Use Pivot Table as View in SQL Server

I have got a pivot table. I prepared it in SQL. But I cant use this table in View. I using SQL Server 2008.
See this answer to a somewhat related question:
sql-pivoted-table-is-read-only-and-cells-cant-be-edited
You need to make the view updateable via an INSTEAD OF trigger, and there are specific conditions to using that trigger, such as the pivot-table view being fully identifiable to source record-column.

How to mimick Oracle Materialized Views on MS SQL Server?

Application connected to MS SQL Server will create views where a single row result is an analysis including aggregations of 1-10k records. The applicable criteria across the resulting view will have dozens to tens of thousands of results. The view+criteria will then be ordered by some column (user specified) in the view which are most likely to be the aggregated columns. Response times are expected to degrade quickly when aggregated column is used for ordering.
A while back, this problem was solved pretty easily (in Oracle 9i) with materialized views.
Any ideas on how to get a similar solution in MS SQL Server 2005.
You can use Indexed views for this.
Read here for SQL 2005: http://msdn.microsoft.com/en-us/library/dd171921.aspx
Read here for SQL 2008: http://msdn.microsoft.com/en-us/library/dd171921.aspx
Materialized views are not same as indexed views. MS SQL server indexed views have multiple limitations such as use of outer joins, aggregates and common table expressions.