Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Postgres-Tuned should tune alignment padding #234

Open
meglio opened this issue Oct 24, 2024 · 4 comments
Open

Postgres-Tuned should tune alignment padding #234

meglio opened this issue Oct 24, 2024 · 4 comments

Comments

@meglio
Copy link

meglio commented Oct 24, 2024

To make the tuned version of the postgres benchmark really tuned, you should optimize the columns layout, see "Column Tetris" at https://stackoverflow.com/a/7431468

@rschu1ze
Copy link
Member

Interesting, thanks for the link. Sounds similar to struct padding in C++.

I guess none of us are Postgres experts but if you (or someone else) like to send a PR with a tuned column order, it would be highly welcome (I could do the runtime measurements on a benchmark machine).

@alexey-milovidov
Copy link
Member

Could you please edit the script? Then we will re-run it.

@meglio
Copy link
Author

meglio commented Nov 20, 2024

Here's the CREATE statement with the improved order of columns:

CREATE TABLE hits
(
    WatchID BIGINT NOT NULL,
    UserID BIGINT NOT NULL,
    FUniqID BIGINT NOT NULL,
    ParamPrice BIGINT NOT NULL,
    RefererHash BIGINT NOT NULL,
    URLHash BIGINT NOT NULL,
    EventTime TIMESTAMP NOT NULL,
    ClientEventTime TIMESTAMP NOT NULL,
    LocalEventTime TIMESTAMP NOT NULL,
    EventDate Date NOT NULL,
    CounterID INTEGER NOT NULL,
    ClientIP INTEGER NOT NULL,
    RegionID INTEGER NOT NULL,
    RefererRegionID INTEGER NOT NULL,
    URLRegionID INTEGER NOT NULL,
    IPNetworkID INTEGER NOT NULL,
    SilverlightVersion3 INTEGER NOT NULL,
    CodeVersion INTEGER NOT NULL,
    HID INTEGER NOT NULL,
    RemoteIP INTEGER NOT NULL,
    WindowName INTEGER NOT NULL,
    OpenerName INTEGER NOT NULL,
    SendTiming INTEGER NOT NULL,
    DNSTiming INTEGER NOT NULL,
    ConnectTiming INTEGER NOT NULL,
    ResponseStartTiming INTEGER NOT NULL,
    ResponseEndTiming INTEGER NOT NULL,
    FetchTiming INTEGER NOT NULL,
    CLID INTEGER NOT NULL,
    JavaEnable SMALLINT NOT NULL,
    GoodEvent SMALLINT NOT NULL,
    CounterClass SMALLINT NOT NULL,
    OS SMALLINT NOT NULL,
    UserAgent SMALLINT NOT NULL,
    IsRefresh SMALLINT NOT NULL,
    RefererCategoryID SMALLINT NOT NULL,
    URLCategoryID SMALLINT NOT NULL,
    ResolutionWidth SMALLINT NOT NULL,
    ResolutionHeight SMALLINT NOT NULL,
    ResolutionDepth SMALLINT NOT NULL,
    FlashMajor SMALLINT NOT NULL,
    FlashMinor SMALLINT NOT NULL,
    TraficSourceID SMALLINT NOT NULL,
    SearchEngineID SMALLINT NOT NULL,
    NetMajor SMALLINT NOT NULL,
    NetMinor SMALLINT NOT NULL,
    UserAgentMajor SMALLINT NOT NULL,
    CookieEnable SMALLINT NOT NULL,
    JavascriptEnable SMALLINT NOT NULL,
    IsMobile SMALLINT NOT NULL,
    MobilePhone SMALLINT NOT NULL,
    AdvEngineID SMALLINT NOT NULL,
    IsArtifical SMALLINT NOT NULL,
    WindowClientWidth SMALLINT NOT NULL,
    WindowClientHeight SMALLINT NOT NULL,
    ClientTimeZone SMALLINT NOT NULL,SilverlightVersion1 SMALLINT NOT NULL,
    SilverlightVersion2 SMALLINT NOT NULL,
    SilverlightVersion4 SMALLINT NOT NULL,
    IsLink SMALLINT NOT NULL,
    IsDownload SMALLINT NOT NULL,
    IsNotBounce SMALLINT NOT NULL,
    IsOldCounter SMALLINT NOT NULL,
    IsEvent SMALLINT NOT NULL,
    IsParameter SMALLINT NOT NULL,
    DontCountHits SMALLINT NOT NULL,
    WithHash SMALLINT NOT NULL,
    Age SMALLINT NOT NULL,
    Sex SMALLINT NOT NULL,
    Income SMALLINT NOT NULL,
    Interests SMALLINT NOT NULL,
    Robotness SMALLINT NOT NULL,
    HistoryLength SMALLINT NOT NULL,
    HTTPError SMALLINT NOT NULL,
    SocialSourceNetworkID SMALLINT NOT NULL,
    HasGCLID SMALLINT NOT NULL,
    ParamCurrencyID SMALLINT NOT NULL,
    Title TEXT NOT NULL,
    URL TEXT NOT NULL,
    Referer TEXT NOT NULL,
    FlashMinor2 TEXT NOT NULL,
    BrowserLanguage TEXT NOT NULL,
    BrowserCountry TEXT NOT NULL,
    SocialNetwork TEXT NOT NULL,
    SocialAction TEXT NOT NULL,
    MobilePhoneModel TEXT NOT NULL,
    Params TEXT NOT NULL,
    SearchPhrase TEXT NOT NULL,
    PageCharset TEXT NOT NULL,
    OriginalURL TEXT NOT NULL,
    SocialSourcePage TEXT NOT NULL,
    ParamOrderID TEXT NOT NULL,
    ParamCurrency TEXT NOT NULL,
    OpenstatServiceName TEXT NOT NULL,
    OpenstatCampaignID TEXT NOT NULL,
    OpenstatAdID TEXT NOT NULL,
    OpenstatSourceID TEXT NOT NULL,
    UTMSource TEXT NOT NULL,
    UTMMedium TEXT NOT NULL,
    UTMCampaign TEXT NOT NULL,
    UTMContent TEXT NOT NULL,
    UTMTerm TEXT NOT NULL,
    FromTag TEXT NOT NULL,
    UserAgentMinor VARCHAR(255) NOT NULL,
    HitColor CHAR NOT NULL
);

@rschu1ze
Copy link
Member

rschu1ze commented Nov 25, 2024

Got ERROR: cannot perform COPY FREEZE because the table was not created or truncated in the current subtransaction when I inserted the hits table into Postgres. I used the standard Postgres script (here), and not the tuned script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants