Freelancer: maximmro
Jaa:
Tee ilmoitus työstä

count columns size for specific table

This query allows you to count maximum size for each column from table. Notice that to count exact size you will need to traverse whole table and it will be too expensive. And please specify more correctly what you mean saying "number of unique values"?

Kilpailutyö #3 kilpailussa                                                 need a quick mysql script

Julkinen selvennystaulu

  • maximmro
    maximmro
    • 8 vuotta sitten

    hi, since you don't reply to my last answer I added set and enum to existing query but I don't know how to update information here

    • 8 vuotta sitten
  • maximmro
    maximmro
    • 8 vuotta sitten

    Hi , well I guess I can add SET and ENUM to the current script. Or you actually want to traverse all data and get precise size for each column? Because for second variant I will need to develop completely another script using java and actually it will cost more than 10 bucks. Also second variant could work very and very long depending on your amount of data even if you have a lot of servers. As I mentioned before if there are not so many imprecise data types like varchars then second variant will not help you much.

    • 8 vuotta sitten
  • afterhourstech
    Kilpailun järjestäjä
    • 8 vuotta sitten

    Actually your solution is the closest from all contestants. If you can add SET and ENUM support, I will pick you as winner.

    • 8 vuotta sitten
  • afterhourstech
    Kilpailun järjestäjä
    • 8 vuotta sitten

    hi, I think your solution is very close, but it is missing handling of SET and ENUM values. Don't worry about "expensive" operation, I will run query on sharded cluster with 100 servers

    • 8 vuotta sitten
  • maximmro
    maximmro
    • 8 vuotta sitten

    yes correct, as I mentioned above to retrieve a precise information about size for each column you will need to traverse all data, it will be extremely expensive operation, but it's possible, it will not be a problem if you have a few thousand of record but if there will be millions of them? Also the query will work absolutely fine if you have only precise data types, but if there will be some varchar or etc. then only traverse will help you.

    • 8 vuotta sitten
  • juliancorrea
    juliancorrea
    • 8 vuotta sitten

    This script don't show how much space (bytes) is being consumed by the data in each COLUMN in a specified table, show only the max space available, correct?

    • 8 vuotta sitten
  • maximmro
    maximmro
    • 8 vuotta sitten

    also please notice that this query count correct size for primary keys and foreign keys.

    • 8 vuotta sitten

Näytä lisää kommentteja Käsitellään...