MySQL file system is faster (2)

Source: Internet
Author: User

5. Other features:


In the first step of development, only read-only is implemented, and a read/write version will soon be available.

The current plan is to map database objects to files and directory objects. Let's take a look

Example:

-- 8 <-----------------------------

# Creating a table


Create table invoice (

Invoice_id int (10) unsigned not null auto_increment,

Invoice_no int (10) unsigned DEFAULT '0' not null,

Payee char (40) DEFAULT ''not null,

Primary key (invoice_id ),

KEY payee (payee)

);


# Insert data


Insert into invoice VALUES (1,100, 'Company AB ');

Insert into invoice VALUES (2,101, 'Company Cd ');

Insert into invoice VALUES (3,102, 'Company EF ');


-- 8 <-----------------------------


Because MySQL cannot use the record number, we must create a primary key.

The following directory structure is available:


/Mountpoint/database/table/primary_key/field


In this way, the structure of the file tree is as follows:


/Mnt/mysql/mydata/invoice/1/invoice_id

/Mnt/mysql/mydata/invoice/1/invoice_no

/Mnt/mysql/mydata/invoice/1/payee

/Mnt/mysql/mydata/invoice/2/invoice_id

/Mnt/mysql/mydata/invoice/2/invoice_no

/Mnt/mysql/mydata/invoice/2/payee

/Mnt/mysql/mydata/invoice/3/invoice_id

/Mnt/mysql/mydata/invoice/3/invoice_no

/Mnt/mysql/mydata/invoice/3/payee

In addition, the second method can be used:


/Mountpoint/database/table/. table

And

/Mountpoint/database/table/primary_key/. record

/Mnt/mysql/mydata/invoice/. table

/Mnt/mysql/mydata/invoice/1/. record

/Mnt/mysql/mydata/invoice/1/invoice_id

/Mnt/mysql/mydata/invoice/1/invoice_no

/Mnt/mysql/mydata/invoice/1/payee

/Mnt/mysql/mydata/invoice/2/. record

/Mnt/mysql/mydata/invoice/2/invoice_id

/Mnt/mysql/mydata/invoice/2/invoice_no

/Mnt/mysql/mydata/invoice/2/payee

/Mnt/mysql/mydata/invoice/3/. record

/Mnt/mysql/mydata/invoice/3/invoice_id

/Mnt/mysql/mydata/invoice/3/invoice_no

/Mnt/mysql/mydata/invoice/3/payee

These files are hidden to prevent duplication. They are mainly used to conveniently use text files.

Browser to view.


Now, when you need to use SQL statements to search for minimum, maximum, and final data,

It can be achieved through symbolic connections:


/Mountpoint/database/table/primary_key/. max

Or

/Mnt/mysql/mydata/invoice/invoice_id/. max

Or point

/Mountpoint/database/table/field

And

/Mnt/mysql/mydata/invoice/3


Similarly, the min, max, sum, avg, and other values of a row can be returned.

This can be implemented quickly and easily.


/Mnt/mysql/mydata/. keys/

/Mnt/mysql/mydata/. keys/invoice_id/

/Mnt/mysql/mydata/. keys/payee/


Symbol to connect to the primary key:

/Mnt/mysql/mydata/. keys/. primary_key/

Actually point

/Mnt/mysql/mydata/. keys/invoice_id/


There are also some hidden files that provide the key type:

/Mnt/mysql/mydata/. keys/invoice_id/. type

/Mnt/mysql/mydata/. keys/payee/. type


The content of the first article is: "primary key", and the second is "KEY.


You can also use indexes to sort records. If you read the following directories:


/Mnt/mysql/mydata/. keys/payee/asc/


The PHP readdir () function connects to the symbols that return data in ascending order.


There are also some global functions:


/Mountpoint/. version

/Mountpoint/. last_insert_id

/Mountpoint/. uptime

/Mountpoint/database/. raid (1, 0/1)

/Mountpoint/database/. type (ISAM/MyISAM/HEAP/DBD)

/Mountpoint/database/. tables

/Mountpoint/database/table/. created

/Mountpoint/database/table/. last_updated

/Mountpoint/database/table/. last_checked

/Mountpoint/database/table/. count


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.