Giter VIP home page Giter VIP logo

Comments (2)

BohuTANG avatar BohuTANG commented on August 16, 2024

Benchmark Round-1: Many rows

Generate Data

INSERT INTO log
SELECT
    (FLOOR(RAND() * 1000000) % 10000)::INT,
    JSON_OBJECT(
        'user_ip', CONCAT_WS(
            '.',
            FLOOR(RAND() * 255)::STRING,
            FLOOR(RAND() * 255)::STRING,
            FLOOR(RAND() * 255)::STRING,
            FLOOR(RAND() * 255)::STRING
        ),
        'request_method', IF(RAND() > 0.5, 'GET', 'POST'),
        'request_url', CONCAT(
            'http://example.com/',
            CASE
                WHEN RAND() < 0.1 THEN 'login'
                WHEN RAND() < 0.2 THEN 'logout'
                WHEN RAND() < 0.3 THEN 'profile'
                WHEN RAND() < 0.4 THEN 'settings'
                WHEN RAND() < 0.5 THEN 'dashboard'
                WHEN RAND() < 0.6 THEN 'search?q=example'
                WHEN RAND() < 0.7 THEN 'help'
                WHEN RAND() < 0.8 THEN 'contact'
                WHEN RAND() < 0.9 THEN 'about'
                ELSE 'home'
            END
        ),
        'response_status', IF(RAND() > 0.5, '200', '404')
    ),
    NOW()
FROM numbers(100000000);

This will take 9min in small warehouse.

Inverted index

cold-run: 19s
hot-run: 5.4s

SELECT count(*)
FROM log
WHERE MATCH(url, 'logout');
image

Like

cold-run: 1.3s
hot-run: 0.5s

SELECT count(*)
FROM log
WHERE url like '%logout%';
image

from databend.

BohuTANG avatar BohuTANG commented on August 16, 2024

Benchmark Round-2: A few rows(152 rows)

Generate Data

INSERT INTO log
SELECT
    (FLOOR(RAND() * 1000000) % 10000)::INT,
    JSON_OBJECT(
        'user_ip', CONCAT_WS(
            '.',
            FLOOR(RAND() * 255)::STRING,
            FLOOR(RAND() * 255)::STRING,
            FLOOR(RAND() * 255)::STRING,
            FLOOR(RAND() * 255)::STRING
        ),
        'request_method', IF(RAND() > 0.5, 'GET', 'POST'),
        'request_url', CONCAT(
            'http://example.com/',
           LEFT(MD5(RAND()::STRING), 5)
        ),
        'response_status', IF(RAND() > 0.5, '200', '404')
    ),
    NOW()
FROM numbers(100000000);

Inverted index

cold-run: 19.4s
hot-run: 0.075s

SELECT count(*)
FROM log
WHERE MATCH(url, '78114');

Like

cold-run: 1.3s
hot-run: 0.6s

SELECT count(*)
FROM log
WHERE url like '%78114%';	

from databend.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.