Variable Ordering in a class.
Constant first then private variables
public> private
static> non-static
final> non-final
injected> normal variable
constructorBy Prithvi Atal, Engineer, Driving High-Performance Solutions
Variable Ordering in a class.
Constant first then private variables
public> private
static> non-static
final> non-final
injected> normal variable
constructorIn this article we will talk about exposing java to Json serialization and how to instrument them
@JsonProperty( "fieldName" ) // Changing the field name
@JsonUnwrapped // Expose child attributes to parent/holder directly instead of as a child
@JsonRootName(value = "user") // Giving root name to the json
JSON to Java schema conversion. :https://www.jsonschema2pojo.org/
Optimize and Improve PostgreSQL Performance with VACUUM, ANALYZE, and REINDEX utility.
VACUUM:
-Reclaims storage occupied by dead tuples with the following commands
AWS RDS show the database load in active session. It shows timeout due to vacuum delay.
REINDEX
It rebuilds one or more indices, replacing the previous version of the index. If an index has become corrupted, and no longer contains valid data, reindex can be executed.
REINDEX INDEX myindex, REINDEX TABLE mytable etc.
ANALYZE
-It collects statistics about specific table columns, entire table, or entire database. The PostgreSQL query planner then uses that data to generate efficient execution plans for queries. Samples:
ANALYZE users; collects statistics for users table.
ANALYZE VERBOSE users; does exactly the same plus prints progress messages.
ANALYZE users (id, display_name); collects statistics for id and display_name columns of users table.
ANALYZE; collects statistics for all table in the current database.
To see the results of actually executing the query, you can use the EXPLAIN ANALYZE command:
EXPLAIN
- To see how a query is executing and adjust the query to be more efficient
EXPLAIN ANALYZE SELECT seqid FROM traffic WHERE serial_id<21;
- Instead of returning the data provides a query plan detailing what approach the planner took to executing the statement provided.
//All above VACUUM, ANALYZE, and REINDEX need to be executed though admin user.
In this article we would be fetching similar records with lookup details.
Consider a retailer needs to know similar order placed along with the customer information.
There are two tables Order and Customer, the SQL query goes like this:
select c.customer_name, c.customer_location, co.brand, co.item_type, co.item_domain, co.item_manufacturer from customer c
inner join (
select o.brand_id, o.brand_id, o.brand_name, o.item_type, o.item_domain, o.item.manufacturer , o.customer_id, from Order o
where o.domain='mobile'
group by o.brand, o.item_type, o.item_domain, o.item.manufacturer
HAVING
COUNT(o. brand_id) > 1
) co on co. customer_id=c. customer_id;