This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| It may not seem like it, but there’s a lot of information packed into those 10 columns! The columns returned by the query are: | |
| id – a sequential identifier for each SELECT within the query (for when you have nested subqueries) | |
| select_type – the type of SELECT query. Possible values are: | |
| SIMPLE – the query is a simple SELECT query without any subqueries or UNIONs | |
| PRIMARY – the SELECT is in the outermost query in a JOIN | |
| DERIVED – the SELECT is part of a subquery within a FROM clause | |
| SUBQUERY – the first SELECT in a subquery | |
| DEPENDENT SUBQUERY – a subquery which is dependent upon on outer query | |
| UNCACHEABLE SUBQUERY – a subquery which is not cacheable (there are certain conditions for a query to be cacheable) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| MariaDB [fun]> EXPLAIN SELECT * FROM users WHERE first_name = 'Martin' AND last_name = 'David'; | |
| +------+-------------+-------+------+----------------------+----------------------+---------+-------------+------+--------------------------+ | |
| | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | | |
| +------+-------------+-------+------+----------------------+----------------------+---------+-------------+------+--------------------------+ | |
| | 1 | SIMPLE | users | ref | first_and_last_names | first_and_last_names | 106 | const,const | 1 | Using where; Using index | | |
| +------+-------------+-------+------+----------------------+----------------------+---------+-------------+------+--------------------------+ | |
| 1 row in set (0.00 sec) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| MariaDB [fun]> CREATE INDEX first_and_last_names ON users (first_name, last_name); | |
| Query OK, 0 rows affected (0.01 sec) | |
| Records: 0 Duplicates: 0 Warnings: 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| MariaDB [fun]> EXPLAIN SELECT * FROM users WHERE first_name = 'Martin' AND last_name = 'David'; | |
| +------+-------------+-------+------+---------------+------+---------+------+------+-------------+ | |
| | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | | |
| +------+-------------+-------+------+---------------+------+---------+------+------+-------------+ | |
| | 1 | SIMPLE | users | ALL | NULL | NULL | NULL | NULL | 10 | Using where | | |
| +------+-------------+-------+------+---------------+------+---------+------+------+-------------+ | |
| 1 row in set (0.00 sec) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| MariaDB [fun]> SELECT * FROM names WHERE first_name = 'Martin' AND last_name = 'David'; | |
| +----+------------+-----------+ | |
| | id | first_name | last_name | | |
| +----+------------+-----------+ | |
| | 10 | Martin | David | | |
| +----+------------+-----------+ | |
| 1 row in set (0.01 sec) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ python cythondemo.py | |
| Elapsed Time: 3.86 second | |
| Ops/second: 25903031.00 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from cpuload import load | |
| import time | |
| if __name__ == '__main__': | |
| max = 100000000 | |
| _start = time.time() | |
| load(10, max) | |
| _end = time.time() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ python setup.py build_ext --inplace | |
| running build_ext | |
| building 'cythondemo' extension | |
| cc -fno-strict-aliasing -fno-common -dynamic -arch i386 -arch x86_64 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c cythondemo.c -o build/temp.macosx-10.11-intel-2.7/cythondemo.o | |
| cythondemo.c:2531:28: warning: unused function '__Pyx_PyObject_AsString' | |
| [-Wunused-function] | |
| static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject* o) { | |
| ^ | |
| cythondemo.c:2528:32: warning: unused function '__Pyx_PyUnicode_FromString' | |
| [-Wunused-function] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from setuptools import setup, Extension | |
| setup(ext_modules=[Extension("cpuload", ["cpuload.c"])], | |
| name='cpuload', | |
| version='0.0.1', | |
| description='A simple Cython demo', | |
| long_description='A simple Cython demo', | |
| keywords='cython demo', | |
| author='Batista Harahap', |