Programming


blog.udartsev.ru

All about programming languages and practicing is here.


Настройка PHP7 Pthreads + Apache на серверах Oracle SunFire

Закидываю рабочую настройку Apache 2.4 + PHP7 with pThreads. Всё настраивалось на серверах Oracle с многопоточным процессором Sun4v.


APACHE --htmldir=/www --prefix=/etc/apache2 --enable-so

copy PHP from: git clone https://github.com/php/php-src.git --depth=1

PHP7 pthreads 1) скачать и скопировать pthreads в /soft/php-7.0.*/ext/pthreads 2) выполнить sudo ./buildconf --force 3) выполнить sudo ./configure --prefix=/etc/php7 --with-apxs2=/etc/apache2/bin/apxs --enable-bcmath --with-zlib=/usr/local --with-curl=/usr/include/curl --with-pcre-dir=/usr/include --with-gettext=/usr/include --with-pgsql=/usr/lib/postgresql/9.5 --enable-zip --with-pear=/etc/php7 --with-tsrm-pthreads --enable-maintainer-zts --with-zlib=/usr/local --with-openssl --enable-pthreads=shared --disable-cli --enable-cli --enable-iconv --enable-mbstring

NORMAL 3) выполнить sudo ./configure --prefix=/etc/php7 --with-apxs2=/etc/apache2/bin/apxs --with-bz2 --with-zlib --enable-zip --enable-soap --enable-intl --with-mcrypt --with-openssl --with-readline --with-curl --enable-pcntl --with-gettext --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-xsl --enable-bcmath --enable-mbstring --enable-calendar --enable-simplexml --enable-json --enable-hash --enable-session --enable-xml --enable-wddx --enable-opcache --with-pcre-regex --with-config-file-path=/etc/php7 --with-config-file-scan-dir=/etc/php7 --with-pgsql

CONFIGURE_STRING="--prefix=/etc/php7 --with-bz2 --with-zlib --enable-zip --disable-cgi --enable-soap --enable-intl --with-mcrypt --with-openssl --with-apxs2=/etc/apache2/bin/apxs --with-pgsql=/usr/lib/postgresql/9.5 --with-readline --with-curl --enable-ftp --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-sockets --enable-pcntl --with-pspell --with-enchant --with-gettext --with-gd --enable-exif --with-jpeg-dir --with-png-dir --with-freetype-dir --with-xsl --enable-bcmath --enable-mbstring --enable-calendar --enable-simplexml --enable-json --enable-hash --enable-session --enable-xml --enable-wddx --enable-opcache --with-pcre-regex --with-config-file-path=/etc/php7/cli --with-config-file-scan-dir=/etc/php7/etc --enable-cli --enable-maintainer-zts --with-tsrm-pthreads --enable-debug --enable-fpm --with-fpm-user=www-data --with-fpm-group=www-data"

./configure $CONFIGURE_STRING

SOLARIS10: --with-openssl=/usr/sfw/include/openssl

CONFIGURE_STRING="--prefix=/etc/php7 --with-bz2 --with-zlib --enable-zip --disable-cgi --enable-soap --enable-intl --with-mcrypt --with-pgsql --with-readline --with-curl --enable-ftp --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-sockets --enable-pcntl --with-pspell --with-enchant --with-gettext --with-gd --enable-exif --with-jpeg-dir --with-png-dir --with-freetype-dir --with-xsl --enable-bcmath --enable-mbstring --enable-calendar --enable-simplexml --enable-json --enable-hash --enable-session --enable-xml --enable-wddx --enable-opcache --with-pcre-regex --with-config-file-path=/etc/php7/cli --with-config-file-scan-dir=/etc/php7 --enable-cli --enable-maintainer-zts --with-tsrm-pthreads --enable-debug --enable-fpm --with-fpm-user=www-data --with-fpm-group=www-data"

./configure $CONFIGURE_STRING



Немного про быстродействие PostgreSQL. Поисковые запросы и индексы.

Из личного опыта по оптимизации PostgreSQL базы данных.

Объем строк: >>> 800067 raws.

Строки типа: TEXT

Разбитие строк: ,TEXT1,TEXT2,TEXT3,~~~,

>>> 800067 raws.   
 ALTER TABLE table.list ADD COLUMN itemnameTSVector TSVECTOR;
    UPDATE table.list SET itemnameTSVector = to_tsvector(itemname);
    CREATE INDEX list_GINindex ON table.list 
        USING GIN(itemnameTSVector);

Поисковый запрос без использования индекса:

>>> 7.2 sec.
SELECT * FROM table.list
WHERE itemname LIKE '%TEXT1%' 
    and itemname LIKE '%TEXT3%';

Поисковый запрос с использованием индекса:

 >>> 7.0 sec.
SELECT * FROM table.list
WHERE tsvector(itemnameTSVector)
    @@ tsquery('TEXT1 & TEXT3');

Далее пробовал с поисковым запросом без индекса, но с запятыми, как с разделителями:

>>> 7.0 sec.
SELECT * FROM table.list
WHERE itemname LIKE '%,TEXT1,%' 
    and itemname LIKE '%,TEXT3,%';

Вот и вся оптимизация. Результат на лицо.


Big Data Algorythms Complexities [bigocheatsheet.com]

Have found smth. interesting here => http://bigocheatsheet.com/

Know Thy Complexities!

Hi there! This webpage covers the space and time Big-O complexities of common algorithms used in Computer Science. When preparing for technical interviews in the past, I found myself spending hours crawling the internet putting together the best, average, and worst case complexities for search and sorting algorithms so that I wouldn't be stumped when asked about them. Over the last few years, I've interviewed at several Silicon Valley startups, and also some bigger companies, like Google, Facebook, Yahoo, LinkedIn, and eBay, and each time that I prepared for an interview, I thought to myself "Why hasn't someone created a nice Big-O cheat sheet?". So, to save all of you fine folks a ton of time, I went ahead and created one. Enjoy! - Eric

enter image description here enter image description here enter image description here