| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
PostgreSQL.Count
Synopsis
- data SQLOperationCounts = SQLOperationCounts {}
- data TableName = TableName {
- tableSchema :: Maybe Text
- tableName :: Text
- subtractCounts :: SQLOperationCounts -> SQLOperationCounts -> SQLOperationCounts
- printCounts :: MonadIO m => SQLOperationCounts -> m ()
- printCountsBrief :: MonadIO m => SQLOperationCounts -> m ()
- renderCounts :: SQLOperationCounts -> String
- renderCountsBrief :: SQLOperationCounts -> String
- prettyCounts :: SQLOperationCounts -> Doc
- prettyCountsBrief :: SQLOperationCounts -> Doc
Counting SQL operations
data SQLOperationCounts Source #
This tracks the number of SQL operations that have been performed, along with which table they were performed on (where possible).
INSERT, DELETE and UPDATE operations act on one table only, so we can tally the number
of each that are performed on each table (indexed by a TableName).
SELECT operations can act on multiple tables, so we just track the total number of selects.
If required, SQLOperationCounts can be constructed using Monoid, added using Semigroup,
and subtracted using subtractCounts.
We use non-negative Naturals as a tally since a negative number of operations makes no sense.
Constructors
| SQLOperationCounts | |
Fields | |
Instances
The name of a table, optionally qualified with a schema.
Instances
| Generic TableName Source # | |
| Show TableName Source # | |
| Eq TableName Source # | |
| Ord TableName Source # | |
| Pretty TableName Source # | |
Defined in PostgreSQL.Count Methods pPrintPrec :: PrettyLevel -> Rational -> TableName -> Doc # pPrintList :: PrettyLevel -> [TableName] -> Doc # | |
| type Rep TableName Source # | |
Defined in PostgreSQL.Count type Rep TableName = D1 ('MetaData "TableName" "PostgreSQL.Count" "postgresql-operation-counting-0.1.0.1-inplace" 'False) (C1 ('MetaCons "TableName" 'PrefixI 'True) (S1 ('MetaSel ('Just "tableSchema") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe Text)) :*: S1 ('MetaSel ('Just "tableName") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text))) | |
subtractCounts :: SQLOperationCounts -> SQLOperationCounts -> SQLOperationCounts Source #
Subtract one set of counts from another. Note that the results are all still Naturals,
so will all be non-negative.
Pretty-printing
printCounts :: MonadIO m => SQLOperationCounts -> m () Source #
Print an SQLOperationCounts to stdout using prettyCounts.
For less verbose output, see printCountsBrief.
printCountsBrief :: MonadIO m => SQLOperationCounts -> m () Source #
Print an SQLOperationCounts to stdout using prettyCountsBrief.
For more verbose output, see printCounts.
renderCounts :: SQLOperationCounts -> String Source #
Render an SQLOperationCounts using prettyCounts.
For less verbose output, see renderCountsBrief.
For more control over how the Doc gets rendered, use renderStyle with a custom style.
renderCountsBrief :: SQLOperationCounts -> String Source #
Render an SQLOperationCounts using prettyCountsBrief.
For more verbose output, see renderCounts.
For more control over how the Doc gets rendered, use renderStyle with a custom style.
prettyCounts :: SQLOperationCounts -> Doc Source #
Pretty-print an SQLOperationCounts using Text.PrettyPrint.
For each Map, we'll print one line for each table. For less verbose output,
see prettyCountsBrief.
This is also the implementation of pPrint for SQLOperationCounts.
prettyCountsBrief :: SQLOperationCounts -> Doc Source #
Pretty-print an SQLOperationCounts using Text.PrettyPrint.
For each Map, we'll print just the sum of the counts. For more verbose output,
see prettyCounts.