Changes between Version 2 and Version 3 of StorageConfigurationOptimizationScore


Ignore:
Timestamp:
01/29/26 16:51:31 (10 days ago)
Author:
233194
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • StorageConfigurationOptimizationScore

    v2 v3  
    102102{{{
    103103storage_configs =
    104   π_{b.id ⇒ build_id, b.total_price,
    105      ssd.brand ⇒ ssd_brand, ssd.capacity ⇒ ssd_capacity, ssd.price ⇒ ssd_price,
    106      hdd.capacity ⇒ hdd_capacity, hdd.price ⇒ hdd_price,
     104  π_{b.id ⇒ build_id,
     105     b.total_price,
     106     ssd_comp.brand ⇒ ssd_brand,
     107     ssd_storage.capacity ⇒ ssd_capacity,
     108     ssd_comp.price ⇒ ssd_price,
     109     hdd_storage.capacity ⇒ hdd_capacity,
     110     hdd_comp.price ⇒ hdd_price,
    107111     CASE
    108        WHEN hdd.capacity IS NULL THEN 'SSD-Only'
    109        WHEN ssd.capacity < 512 THEN 'SSD-Boot-HDD-Storage'
     112       WHEN hdd_storage.capacity IS NULL THEN 'SSD-Only'
     113       WHEN ssd_storage.capacity < 512 THEN 'SSD-Boot-HDD-Storage'
    110114       ELSE 'SSD-Primary-HDD-Archive'
    111115     END ⇒ config_type
    112116  } (
    113     σ_{ssd_comp.type = 'SSD' AND (hdd_comp.type = 'HDD' OR hdd_comp.type IS NULL)} (
     117    σ_{ssd_comp.type = 'storage' AND
     118       b.is_approved = TRUE AND
     119       b.created_at ≥ CURRENT_DATE - INTERVAL '1 year' AND
     120       (ssd_storage.type ILIKE '%nvme%' OR
     121        ssd_storage.type ILIKE '%ssd%' OR
     122        ssd_storage.type ILIKE '%m.2%' OR
     123        ssd_storage.form_factor ILIKE '%m.2%') AND
     124       (hdd_storage.component_id IS NULL OR
     125        hdd_storage.type ILIKE '%hdd%' OR
     126        hdd_storage.form_factor ILIKE '%3.5%')
     127    } (
    114128      build b
    115129      ⋈_{b.id = bc_ssd.build_id} build_component bc_ssd
    116130      ⋈_{bc_ssd.component_id = ssd_comp.id} components ssd_comp
    117       ⟕_{b.id = bc_hdd.build_id AND bc_hdd.component_id = hdd_comp.id AND hdd_comp.type = 'HDD'}
    118         (build_component bc_hdd ⋈ components hdd_comp)
     131      ⋈_{ssd_storage.component_id = ssd_comp.id} storage ssd_storage
     132      ⟕_{b.id = bc_hdd.build_id} build_component bc_hdd
     133      ⟕_{bc_hdd.component_id = hdd_comp.id} components hdd_comp
     134      ⟕_{hdd_storage.component_id = hdd_comp.id} storage hdd_storage
    119135    )
    120136  )
    121137
    122138config_performance =
    123   γ_{config_type, ssd_brand;
    124      COUNT(build_id) ⇒ builds_count,
    125      AVG(ssd_price + COALESCE(hdd_price, 0)) ⇒ avg_storage_cost,
    126      AVG(ssd_capacity + COALESCE(hdd_capacity, 0)) ⇒ avg_total_capacity,
     139  γ_{sc.config_type, sc.ssd_brand;
     140     COUNT(sc.build_id) ⇒ builds_count,
     141     AVG(sc.ssd_price + COALESCE(sc.hdd_price, 0)) ⇒ avg_storage_cost,
     142     AVG(sc.ssd_capacity + COALESCE(sc.hdd_capacity, 0)) ⇒ avg_total_capacity,
    127143     AVG(rb.value) ⇒ avg_build_rating,
    128      AVG((ssd_price + COALESCE(hdd_price, 0)) / total_price) ⇒ storage_cost_ratio
     144     AVG((sc.ssd_price + COALESCE(sc.hdd_price, 0)) / NULLIF(sc.total_price, 0)) ⇒ storage_cost_ratio
    129145  } (
    130     σ_{b.is_approved = TRUE AND b.created_at ≥ CURRENT_DATE - INTERVAL '1 year'} (
    131       storage_configs sc ⋈_{sc.build_id = b.id} build b
    132       ⋈_{sc.build_id = rb.build_id} rating_build rb
    133     )
     146    storage_configs sc
     147    ⟕_{sc.build_id = rb.build_id} rating_build rb
    134148  )
     149  WHERE builds_count ≥ 2
    135150
    136151λ_15 (
    137152  τ_{optimization_score DESC, builds_count DESC} (
    138     σ_{builds_count ≥ 5} (
    139       π_{cp.config_type,
    140          cp.ssd_brand,
    141          cp.builds_count,
    142          ROUND(cp.avg_storage_cost, 2) ⇒ avg_storage_cost,
    143          ROUND(cp.avg_total_capacity, 0) ⇒ avg_total_capacity_gb,
    144          ROUND(cp.avg_build_rating, 2) ⇒ avg_build_rating,
    145          ROUND(cp.storage_cost_ratio * 100, 1) ⇒ storage_cost_pct,
    146          ROUND(
    147            (cp.avg_build_rating / 5.0 * 40) +
    148            (cp.avg_total_capacity / cp.avg_storage_cost * 0.5) +
    149            ((1 - cp.storage_cost_ratio) * 30) +
    150            (LOG(cp.builds_count) * 5),
    151            2
    152          ) ⇒ optimization_score
    153       } (config_performance cp)
    154     )
     153    π_{cp.config_type,
     154       cp.ssd_brand,
     155       cp.builds_count,
     156       ROUND(cp.avg_storage_cost, 2) ⇒ avg_storage_cost,
     157       ROUND(cp.avg_total_capacity, 0) ⇒ avg_total_capacity_gb,
     158       ROUND(COALESCE(cp.avg_build_rating, 0), 2) ⇒ avg_build_rating,
     159       ROUND(COALESCE(cp.storage_cost_ratio, 0) * 100, 1) ⇒ storage_cost_pct,
     160       ROUND(
     161         (COALESCE(cp.avg_build_rating, 0) / 5.0 * 40) +
     162         (cp.avg_total_capacity / NULLIF(cp.avg_storage_cost, 0) * 0.5) +
     163         ((1 - COALESCE(cp.storage_cost_ratio, 0)) * 30) +
     164         (LN(cp.builds_count + 1) * 5),
     165         2
     166       ) ⇒ optimization_score
     167    } (config_performance cp)
    155168  )
    156169)