eEcho blog

is een halte van de gedachte

Archive for the ‘Database’ Category

parsing overhead mysql (OR of IN)

if you need to fetch multiple headlines, and you know their IDs? Should you use OR or IN(…)? Let’s find out what MySQL can tell us, using the lowest and highest headline IDs as well as one in between:
mysql> SELECT Url FROM Headline WHERE Id IN(1531513, 10231599, 13962322);
+———————————————-+
| Url […]

Using EXPLAIN

EXPLAIN command to help figure that out. In doing so, we’ll see how adding an index or simply rephrasing a query can often better use an existing index and greatly improve performance.
mysql> describe individual
-> ;
+————+—————+——+—–+———+——-+
| Field | Type […]

Parsing, Analysis, and Optimization Mysql

Before MySQL can do anything interesting (or useful) with a noncached query, it must parse the query into its component parts. As part of that process, it verifies that the query is syntactically valid and gathers some basic information about the query:
What type of query is this? Is it […]

Query Cache Mysql

You can enable the query cache (available as of MySQL 4.0.1) by setting query_cache_type to an appropriate value in my.cnf:
query_cache_type = 1
As far as the cache is concerned, the query:
SELECT * FROM table1
is different from:
select * FROM table1
It is possible to tell MySQL that it should not cache a given query, however. The way to […]

Query Processing Basics mysql

How MySQL goes from receiving a query to sending the results back to a client is relatively straightforward. The work happens in several distinct stages. Let’s walk through them.

Mysql Replication

Replication enables data from one MySQL database server (called the master) to be replicated to one or more MySQL database servers (slaves). Replication is asynchronous - your replication slaves do not need to be connected permanently to receive updates from the master, which means that updates can occur over long-distance connections and even temporary solutions […]

MySQL Performance Blog

This page lists MySQL related Talks MySQL Performance Blog team members gave during the last years. Hope you find them helpful.
http://www.mysqlperformanceblog.com/mysql-performance-presentations/

BACKING UP YOUR MYSQL DATABASE

To make a backup copy of your mysql database via a SSH session:
mysqldump -e –force –quick -h mysqlhost -u Username -pPassword DatabseID > dbBackupFile.sql

backup/restore gbk characters and blob
mysqldump -hmysql.netfirms.com -uUsername -Password DatabseID –hex-blob –force > test.sql
Or you can load data in file
mysql -hmysql.eecho.info -P3306 -p111111 -uMyAdminUser dmydatabase

LOAD DATA LOCAL INFILE ‘E:\\Echo\\MySql_Server\\BackUps\\tbl_pagina.txt’ REPLACE INTO […]

CONNECTING TO A MYSQL DATABASE

To connect to a mysql database via a SSH session: (where Username is the database username and dbid is the database id):

%mysql -A -uUsername -pPassword DatabaseID

Mysql Linux restart

* To start mysql server:
# /etc/init.d/mysql start
* To stop mysql server:
# /etc/init.d/mysql stop

* To restart mysql server
# /etc/init.d/mysql restart

Mysql Restore backup in SH Ubuntu

Met sh database automatisch terug zetten.
Maak een sh bestand aan
vim resetDB-shell

Inhoud ervan is hier
#!/bin/sh
sudo mysql -hlocalhost -pwachtwoord -uroot –force -e “DROP DATABASE eEchoDB”
sudo mysql -hlocalhost -pwachtwoord -uroot –force < eEchoDB_20080429_1242.sql
Maak het uitvoerbaar

chmod -R 775 resetDB-shell
run

./resetDB-shell

How MySQL Uses Indexes

http://dev.mysql.com/doc/refman/5.0/en/mysql-indexes.html
indexes are used to find rows with specific column values quickly. Without an index, MySQL must begin with the first row and then read through the entire table to find the relevant rows. The larger the table, the more this costs. If the table has an index for the columns in question, MySQL can quickly […]

CREATE UNIQUE INDEX MySQL

CREATE INDEX is mapped to an ALTER TABLE statement to create indexes. See Section 12.1.2, “ALTER TABLE Syntax”. CREATE INDEX cannot be used to create a PRIMARY KEY; use ALTER TABLE instead. For more information about indexes, see Section 7.4.5, “How MySQL Uses Indexes”.
http://dev.mysql.com/doc/refman/5.0/en/mysql-indexes.html

CREATE UNIQUE INDEX keyword ON `eEcho`.`keyword` (keyword(128));
http://dev.mysql.com/doc/refman/5.0/en/create-index.html

Comparison Functions and Operators MySQL

http://dev.mysql.com/doc/refman/5.0/en/comparison-operators.html
BETWEEN … AND … Check whether a value is within a range of values
COALESCE() Return the first non-NULL argument
<=> NULL-safe equal to operator
= Equal operator
>= Greater than or equal operator
> Greater than operator
GREATEST() Return the largest argument
IN() Check whether a value is within a set of values
INTERVAL() Return the index of the argument that is […]

mysql datetime

DATETIME, DATE, and TIMESTAMP Types
http://dev.mysql.com/doc/refman/5.0/en/datetime.html
Problems Using DATE Columns ( datetime mysql compare )
http://dev.mysql.com/doc/refman/5.0/en/using-date.html
Date and Time Functions
http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html

Google Base Data API

http://code.google.com/apis/base/
What is the Google Base data API?
The Google Base data API enables developers to :
* query Google Base data to create applications and mashups.
* input and manage Google Base items programmatically.
*
Developer’s Guide
[…]

Row Subqueries MySql

http://dev.mysql.com/doc/refman/5.0/en/row-subqueries.html
The discussion to this point has been of scalar or column subqueries; that is, subqueries that return a single value or a column of values. A row subquery is a subquery variant that returns a single row and can thus return more than one column value. Here are two examples:

SELECT * FROM t1 WHERE (1,2) […]

Subquery Syntax Mysql

http://dev.mysql.com/doc/refman/5.0/en/subqueries.html
Subquery is nested voorbeeld:

SELECT * FROM t1 WHERE column1 = (SELECT column1 FROM t2);

They allow queries that are structured so that it is possible to isolate each part of a statement.
They provide alternative ways to perform operations that would otherwise require complex joins […]

Java eclipse jdbc connector

- Maak een nieuwe project aan. / File / New project / Java Project /
- Geef een naam voor de project, klik “Next”
- In volgende venster /tab Libraries/ klik op de knop “Add externeal JARS”
- Blader naar de map waar mysql-connector-java-X.X.X -bin.jar zich bevind en selecteer hem. “OK” […]

SQLite populatie exporteren in Mysql

Met sqlite kan een database geëxporteerd worden structuur + populatie. (.sql format )
http://sqlitebrowser.sourceforge.net/
Deze toepassing is platform onafhankelijk.
- Download toepassing.
- Run zonder installatie
- Blader naar Sqlite database
- Selecteer tabellen die geëxporteerd moeten worden
- Kies sql als formaat.
- Open deze (.sql ) bestand met tekst editor (zoals kladblok, geditor, ezv)
- Kies opslaan als
- Kies onderaan codering […]

 

Home | info@eecho.info | Voorwaarden | Blog