MySQL views: 200 views chain limit?

I’m doing some stress test with MySQL on views…

– i created a chain of very simple views:
CREATE VIEW view1 AS SELECT * FROM `table1`;
CREATE VIEW view2 AS SELECT * FROM `view1`;
CREATE VIEW view3 AS SELECT * FROM `view2`;
….
(table1 contains 1000 records) i created 200 of them and it seems that MySQL manages them very good…
mysql> SELECT empno FROM table1 WHERE birthdate=”1953-04-08″;
2 rows in set (0.00 sec)
mysql> SELECT empno FROM view1 WHERE birthdate=”1953-04-08″;
2 rows in set (0.00 sec)
mysql> SELECT empno FROM view50 WHERE birthdate=”1953-04-08″;
2 rows in set (0.00 sec)
mysql> SELECT empno FROM view100 WHERE birthdate=”1953-04-08″;
2 rows in set (0.00 sec)
mysql> SELECT empno FROM view200 WHERE birthdate=”1953-04-08″;
2 rows in set (0.01 sec)
this were the first executions of the views… the system might have cached something but not a lot…
– then i created other 300 views (all the way to view500)… MySQL tends to panic… lost connection, or sometimes gets extremely slow…
(here i change the date in the WHERE to avoid cache, this is why we have empty set)
mysql> SELECT empno FROM view100 WHERE birthdate=”1953-04-09″;
Empty set (0.00 sec)
mysql> SELECT empno FROM view200 WHERE birthdate=”1953-04-09″;
Empty set (0.01 sec)
mysql> SELECT empno FROM view300 WHERE birthdate=”1953-04-09″;
ERROR 2013 (HY000): Lost connection to MySQL server during query

mysql> SELECT empno FROM view300 WHERE birthdate=”1953-04-09″;
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect…
Connection id: 1
Current database: viewstresstest
ERROR 2013 (HY000): Lost connection to MySQL server during query


I tested a little further and the problem seems to be in the chain somewhere between 200 and 205 views…
My feeling is that the problem relies in the implementation and is not a theoretical limitation of the scalability, cause the performance drop is too sudden to be intrinsic in the approach…
I posted it on the MySQL forum but I’ve got no answer so far…

If someone plans to repeat the test , this is the script for generating the views:

#!/bin/bash
numberofview=$1;
echo “CREATE VIEW view1 AS SELECT * FROM \`table1\`;”;
for((cv=2;$cv<=$numberofview;cv=$(($cv+1))));
do
cvold=$(($cv-1));
echo “CREATE VIEW view$cv AS SELECT * FROM \`view$cvold\`;”
done

VSDB: Very Small Data Base

 

This was one of my first topic of interest. As a Bachelor thesis i developed, guided by Cristiana Bolchini and Letizia Tanca the PoLiDBMS tool discussed in the following.

The use of handheld devices, such as Smart Cards, Portable Data Assistants (PDA), Palm PCs and Cell Phones, to store data locally and to issue transactions against both local and remote data from Information Systems is being widely discussed in recent times.

Features required by portable devices in order to manage data are, for some aspects, similar to those found in Embedded Database systems, and range from very simple file system functions to a full set of database management capabilities, including some ACID transactions properties. Databases for very small devices – henceforth called Very Small Data Bases (VSDB) – are useful in various circumstances:

The personal (micro)information system, the so-called citizen’s card, which records administrative personal data like driver’s license and car information, passport, judicial register, etc.;

The personal medical record, reporting the owner’s clinical history complete with all the past clinical tests and diagnoses; this is most useful with patients suffering from some form of physical handicap or needing some critical treatment like periodical dialysis;

The traveling salesman database, i.e. the “clients portfolio”, storing visit schedule and purchase orders along with the interesting information about each client’s particular needs;

The personal travel database, recording all the travel (e.g. touristic) information considered interesting by the device owner.

 

In this scenario a twofold research project began a couple of years ago, to tackle the problems of a) efficiently managing data stored locally on devices with limited resources – the VSDB DataBase Management System – and b) designing and selecting the portion of data to be held – the VDSB Design Methodology -.

The two aspects of the problem are strictly related and the research has at first investigated the opportunity to define new physical and logical data structures to exploit the technological characteristics of the digital mobile devices hosting the DBMS and the data. On top of such ad-hoc data structures a Portable Light DBMS has been designed and a prototype is currently available (namecode: PoLiDBMS), to process query and manage the stored data.

On the other hand, we also worked on the design methodology to define the DB to be stored locally on the device and be readily available to the user.

More specifically, the methodology we propose for Very Small Data Base design is based on the classical three levels of the ANSI-SPARC model, sharing many issues with the methodologies for distributed/federated database design. However, three main differences w.r.t. the traditional design methodologies are introduced: first, since most interesting microdevices are portable, the main mobility issues are to be considered along with data distribution; second, context awareness is included in the data design issues to allow a full exploitation of context sensitive application functionalities; third, the peculiarities of the storage device(s) must be taken into account from the early steps, thus a logistic phase is added after the usual conceptual and logical phases, which supports the designer in the physical design task by taking into account the logistic aspects of data storage.

By examining these three aspects together we delineate the “VSDB ambient”, which isthe set of personal and environmental characteristics determining the portion of data that must be stored on the portable device.

About me

My Personal Interest
I play keyboard (piano, synth and samplers) in a Rock-Pop Band named Moksha. I love sports, i’ve practiced Water-polo and Judo at agonistic level. During summer Beach-Volley becomes a must, together with Kite-Surf and Canoa. I play as an actor in the small drama company “La Corte Dei Miracoli”. I’m currently part of the no-profit organization “Ingegneria Senza Frontiere”. I’m currently studying Modern Dancing (Hip-Hop and Jazz).